private void setUpMap() { mMap.setMyLocationEnabled(true); mMap.setOnMyLocationButtonClickListener(this); mMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() { @Override public void onInfoWindowClick(Marker marker) { String title = marker.getTitle(); int resId = mMarkerInfoMap.get(marker).getResId(); Intent intent = new Intent(RoutesMapFragment.this.getActivity(), PointOfInterestActivity.class); intent.putExtra(Constants.INTENT_TITLE, title); intent.putExtra(Constants.INTENT_RES_ID, resId); intent.putExtra(Constants.INTENT_TAB, 1); intent.putExtra(Constants.INTENT_POSITION, mMarkerInfoMap.get(marker).getPosition()); intent.putExtra(Constants.INTENT_DRAWER_POSITION, 0); RoutesMapFragment.this.getActivity().startActivity(intent); } }); addDefaultMarkers(); goToDefaultLocation(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.mapview); type = getIntent().getStringExtra("type"); facilities = facilitiesManager.get(getApplicationContext()).getFacilities(type); facilityMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); facilityMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() { public void onInfoWindowClick(Marker marker){ Intent i = new Intent(MapActivity.this, facilityInfo.class); i.putExtra("facility", facilityMarkers.get(marker)); i.putExtra("type", type); startActivity(i); } }); Log.i(TAG, "About to add markers for faciltiies"); for (facility f : facilities) { addMarker(f); } Log.i(TAG, "Finished adding markers."); setTitle(getMapTitle()); centerMap(); }
private void setUpMap() { mMap.setMyLocationEnabled(true); mMap.setOnMyLocationButtonClickListener(this); mMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() { @Override public void onInfoWindowClick(Marker marker) { Intent intent = new Intent(PointOfInterestMapFragment.this.getActivity(), PointOfInterestDetailActivity.class); intent.putExtra(Constants.INTENT_TITLE, marker.getTitle()); intent.putExtra(Constants.INTENT_RES_ID, mMarkerInfoMap.get(marker).getResId()); mItemClickedListener.onItemClicked(intent); } }); TypedArray routes = getResources().obtainTypedArray(R.array.routes); int resId = routes.getResourceId(getArguments().getInt(INTENT_POSITION), -1); routes.recycle(); TypedArray route = getResources().obtainTypedArray(resId); mZoom = route.getInteger(2, -1); mDefaultLatitude = route.getFloat(3, -1); mDefaultLongitude = route.getFloat(4, -1); addMarkers(route.getResourceId(5, -1)); route.recycle(); goToDefaultLocation(); }
@Override public void onMapReady(GoogleMap googleMap) { map = googleMap; if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Call ActivityCompat#requestPermissions return; } else { map.setMyLocationEnabled(true); } Service service = (Service) getIntent().getExtras().getSerializable(Utils.ARGS_SERVICE); if (service != null) { drawService(service); } else { new GetMapMarkers().execute(); } map.setOnInfoWindowClickListener(new OnInfoWindowClickListener() { @Override public void onInfoWindowClick(Marker marker) { Intent intent = new Intent().setClass(getApplicationContext(), StationActivity.class); Station station = stationMarkers.get(marker); if (station != null) { Bundle bundle = new Bundle(); bundle.putSerializable(Utils.ARGS_STATION, station); intent.putExtras(bundle); startActivity(intent); } } }); }
/** * when info window is clicked * * @param callback */ public void whenInfoWindowClick(final MarkerCallback callback) { map.setOnInfoWindowClickListener(new OnInfoWindowClickListener() { @Override public void onInfoWindowClick(Marker marker) { callback.invokedMarker(map, marker); } }); }
@Override public final void setOnInfoWindowClickListener(OnInfoWindowClickListener listener) { map.setOnInfoWindowClickListener(listener); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.fragment_home, container, false); dropMap = new HashMap<Marker, Drop>(); if(!isConnected()) { new AlertDialog.Builder(rootView.getContext()) .setTitle("No Connection") .setIcon(android.R.drawable.ic_dialog_alert) .setMessage("Internet not available. You will not be able to see drops. Please check your connectivity and then refresh or reload Drop In.") .setNeutralButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }) .show(); } // get MapView from layout mapView = (MapView) rootView.findViewById(R.id.mapview); mapView.onCreate(savedInstanceState); //get GoogleMap from MapView + initialization map = mapView.getMap(); MapsInitializer.initialize(mapView.getContext()); map.setMyLocationEnabled(true); int actionBarSize = getActionBarHeight(); map.setPadding(0, actionBarSize, 0, actionBarSize); map.getUiSettings().setZoomControlsEnabled(true); refresh(); map.setOnInfoWindowClickListener(new OnInfoWindowClickListener() { @Override public void onInfoWindowClick(Marker marker) { info = new Info_Fragment(dropMap.get(marker)); ft = fm.beginTransaction(); ft.add(R.id.container, info) .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN) .addToBackStack("info") .commit(); } }); return rootView; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Activate Navigation Mode Tabs mActionBar = getSupportActionBar(); mActionBar.setDisplayHomeAsUpEnabled(true); mActionBar.setTitle("La Poste Tunisienne"); mActionBar.setSubtitle("Map des bureaux "); setContentView(R.layout.layout_map); SupportMapFragment frg = new SupportMapFragment(); frg = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); map = frg.getMap(); map.setMapType(GoogleMap.MAP_TYPE_NORMAL); // MyLocation enable : map.setMyLocationEnabled(true); // MyLocation marker // LatLng myStartLocation = new // LatLng(map.getMyLocation().getLatitude(), // map.getMyLocation().getLongitude()); map.setLocationSource(new CurrentLocationProvider(this)); // Marker hamburg = map.addMarker(new // MarkerOptions().position(Menzah9) // .title("Manzah9")); kiel = map.addMarker(new MarkerOptions() .position(Menzah9).title("Menzah9") .snippet("Bureau de Poste")); kiel2 = map.addMarker(new MarkerOptions().position(Hached) .title("Hached").snippet("Bureau de Poste")); Marker kiel3 = map.addMarker(new MarkerOptions().position(Rades) .title("Rades").snippet("Bureau de Poste")); // Move the camera instantly to hamburg with a zoom of 15. map.moveCamera(CameraUpdateFactory.newLatLngZoom(Hached, 21)); // Zoom in, animating the camera. map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null); // OnMarkerDragListener // OnInfoWindowClickListener map.setOnInfoWindowClickListener(new OnInfoWindowClickListener() { @Override public void onInfoWindowClick(Marker marker) { progressDialog = new ProgressDialog(MapActivity.this, ProgressDialog.THEME_HOLO_LIGHT); progressDialog.setIndeterminate(false); progressDialog .setProgressStyle(ProgressDialog.STYLE_SPINNER); progressDialog.setMessage(" Telechargement ..."); progressDialog.show(); Rechercher("hached"); } }); mRequestQueue = ((LaPosteTunisienne) getApplicationContext()) .getVolleyRequestQueue(); URL = ((LaPosteTunisienne) getApplicationContext()).URL; }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = super.onCreateView(inflater, container, savedInstanceState); hsLocation = new LatLng(40.993498, 29.042059); if (getActivity() != null) { int checkGooglePlayServices = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity()); if (checkGooglePlayServices != ConnectionResult.SUCCESS) { // google play services is missing!!!! /* Returns status code indicating whether there was an error. Can be one of following in ConnectionResult: SUCCESS, SERVICE_MISSING, SERVICE_VERSION_UPDATE_REQUIRED, SERVICE_DISABLED, SERVICE_INVALID. */ Log.e("hs", "play services not available"); Log.e("hs", String.valueOf(checkGooglePlayServices)); } else { CameraPosition camPos = new CameraPosition.Builder() .target(hsLocation) .zoom(16) .build(); CameraUpdate update = CameraUpdateFactory.newCameraPosition(camPos); getMap().moveCamera(update); MarkerOptions mrkr = new MarkerOptions(); mrkr.position(hsLocation) .title("İstanbul HackerSpace") .snippet("Click to call - Tel : +90 216 418 04 17") .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher)); getMap().addMarker(mrkr); getMap().setOnInfoWindowClickListener(new OnInfoWindowClickListener() { public void onInfoWindowClick(final Marker marker) { Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:+90 216 418 04 17")); startActivity(callIntent); } }); getMap().setMyLocationEnabled(true); } } return v; }
void setOnInfoWindowClickListener(OnInfoWindowClickListener listener);