@Override protected void startDemo() { mTextView = (TextView) findViewById(R.id.textView); getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(-33.8256, 151.2395), 10)); getMap().setOnMarkerDragListener(this); mMarkerA = getMap().addMarker(new MarkerOptions().position(new LatLng(-33.9046, 151.155)).draggable(true)); mMarkerB = getMap().addMarker(new MarkerOptions().position(new LatLng(-33.8291, 151.248)).draggable(true)); mPolyline = getMap().addPolyline(new PolylineOptions().geodesic(true)); Toast.makeText(this, "Drag the markers!", Toast.LENGTH_LONG).show(); showDistance(); }
@Override public void onMapReady(final GoogleMap map) { if (needsInit) { CameraUpdate center= CameraUpdateFactory.newLatLng(new LatLng(40.76793169992044, -73.98180484771729)); CameraUpdate zoom=CameraUpdateFactory.zoomTo(15); map.moveCamera(center); map.animateCamera(zoom); } addMarkers(map); map.setInfoWindowAdapter(new PopupAdapter(getLayoutInflater(), models)); map.setOnInfoWindowClickListener(this); }
private void setUpMap() { map.setMyLocationEnabled(true); map.animateCamera(zoomToLastKnownLatLng()); }
@Override public void setZoom(int zoom) { googleMap.animateCamera( CameraUpdateFactory.newLatLngZoom(googleMap.getCameraPosition().target, zoom)); }
@SuppressLint("MissingPermission") private void follow() { if (map!=null && locMgr!=null) { if (autoFollow) { locMgr.requestLocationUpdates(0L, 0.0f, crit, this, null); map.setLocationSource(this); map.getUiSettings().setMyLocationButtonEnabled(false); } else { map.getUiSettings().setMyLocationButtonEnabled(true); map.setLocationSource(null); locMgr.removeUpdates(this); } } } }
@Override public void onMapReady(GoogleMap map) { CameraUpdate center= CameraUpdateFactory.newLatLng(new LatLng(40.76793169992044, -73.98180484771729)); CameraUpdate zoom=CameraUpdateFactory.zoomTo(15); map.moveCamera(center); map.animateCamera(zoom); } }
private void addMarker(GoogleMap map, double lat, double lon, int title, int snippet, String image) { Marker marker= map.addMarker(new MarkerOptions().position(new LatLng(lat, lon)) .title(getString(title)) .snippet(getString(snippet))); if (image != null) { images.put(marker.getId(), Uri.parse("http://misc.commonsware.com/mapsv2/" + image)); } } }
CameraUpdate zoom=CameraUpdateFactory.zoomTo(15); map.moveCamera(center); map.animateCamera(zoom); .width(5).color(Color.RED); map.addPolyline(line); .strokeColor(Color.BLUE); map.addPolygon(area); map.setInfoWindowAdapter(new PopupAdapter(getLayoutInflater())); map.setOnInfoWindowClickListener(this);
/** * Displays a {@link LiteListDemoActivity.NamedLocation} on a * {@link com.google.android.gms.maps.GoogleMap}. * Adds a marker and centers the camera on the NamedLocation with the normal map type. */ private void setMapLocation() { if (map == null) return; NamedLocation data = (NamedLocation) mapView.getTag(); if (data == null) return; // Add a marker for this item and set the camera map.moveCamera(CameraUpdateFactory.newLatLngZoom(data.location, 13f)); map.addMarker(new MarkerOptions().position(data.location)); // Set the map type back to normal. map.setMapType(GoogleMap.MAP_TYPE_NORMAL); }
private void displayPlacesOnMap(List<Place> places) { if (map != null) { map.clear(); if (!places.isEmpty()) { LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder(); for (Place place : places) { // Creates a marker at the place location and with the place name LatLng position = place.getPosition(); String placeName = place.get(Place.NAME); if (position != null) { MarkerOptions markerOptions = new MarkerOptions() .position(position) .title(placeName); Marker marker = map.addMarker(markerOptions); marker.setTag(place); boundsBuilder.include(position); } } CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(boundsBuilder.build(), 100); map.moveCamera(cameraUpdate); } } }
@Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; // Add a marker in Sydney and move the camera mMap.addMarker(new MarkerOptions().position(sydney).title("last online:"+ LastDateOnline)); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(sydney,15)); }
@Override public void onLocationChanged(Location location) { //Every time we change location we clear the map and update our zoom and marker location. mMap.clear(); mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()),10)); mMap.addMarker(new MarkerOptions().position(new LatLng(location.getLatitude(), location.getLongitude())).title("Your Location")); updateLocation(location); }
private void addObjectsToMap() { mAdelaideCircle = mMap.addCircle(new CircleOptions() .center(ADELAIDE) .radius(500000) mSydneyGroundOverlay = mMap.addGroundOverlay(new GroundOverlayOptions() .image(BitmapDescriptorFactory.fromResource(R.drawable.harbour_bridge)) .position(SYDNEY, 700000) mHobartMarker = mMap.addMarker(new MarkerOptions().position(HOBART)); mHobartMarker.setTag(new CustomTag("Hobart marker")); mDarwinPolygon = mMap.addPolygon(new PolygonOptions() .add( new LatLng(DARWIN.latitude + 3, DARWIN.longitude - 3), mPolyline = mMap.addPolyline(new PolylineOptions() .add(PERTH, BRISBANE) .color(Color.rgb(103, 24, 173))
@Override public void onMapReady(GoogleMap map) { mMap = map; // Hide the zoom controls. mMap.getUiSettings().setZoomControlsEnabled(false); // Add lots of markers to the map. addMarkersToMap(); // Set listener for marker click event. See the bottom of this class for its behavior. mMap.setOnMarkerClickListener(this); // Set listener for map click event. See the bottom of this class for its behavior. mMap.setOnMapClickListener(this); // Override the default content description on the view, for accessibility mode. // Ideally this string would be localized. map.setContentDescription("Demo showing how to close the info window when the currently" + " selected marker is re-tapped."); LatLngBounds bounds = new LatLngBounds.Builder() .include(PERTH) .include(SYDNEY) .include(ADELAIDE) .include(BRISBANE) .include(MELBOURNE) .build(); mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 50)); }
@Override public void run() { CameraUpdate allTheThings= CameraUpdateFactory.newLatLngBounds(builder.build(), 32); map.moveCamera(allTheThings); } });
@Override protected void startDemo() { getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(51.503186, -0.126446), 10)); mClusterManager = new ClusterManager<MyItem>(this, getMap()); getMap().setOnCameraIdleListener(mClusterManager); try { readItems(); } catch (JSONException e) { Toast.makeText(this, "Problem reading list of markers.", Toast.LENGTH_LONG).show(); } }
@Override public void onMapReady(GoogleMap map) { mMap = map; mMap.setOnCameraIdleListener(this); mMap.setOnCameraMoveStartedListener(this); mMap.setOnCameraMoveListener(this); mMap.setOnCameraMoveCanceledListener(this); // We will provide our own zoom controls. mMap.getUiSettings().setZoomControlsEnabled(false); mMap.getUiSettings().setMyLocationButtonEnabled(true); // Show Sydney mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(-33.87365, 151.20689), 10)); }
mMap.addPolyline(new PolylineOptions() .addAll(line) .color(Color.BLACK)); getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(28.05870, -82.4090), 15)); mMap.addPolyline(new PolylineOptions() .addAll(simplifiedLine) .color(Color.RED - ALPHA_ADJUSTMENT)); mMap.addPolyline(new PolylineOptions() .addAll(simplifiedLine) .color(Color.GREEN - ALPHA_ADJUSTMENT)); mMap.addPolyline(new PolylineOptions() .addAll(simplifiedLine) .color(Color.MAGENTA - ALPHA_ADJUSTMENT)); mMap.addPolyline(new PolylineOptions() .addAll(simplifiedLine) .color(Color.YELLOW - ALPHA_ADJUSTMENT)); mMap.addPolyline(new PolylineOptions() .addAll(simplifiedLine) .color(Color.BLUE - ALPHA_ADJUSTMENT)); mMap.addPolygon(new PolygonOptions() .addAll(triangle) .fillColor(Color.BLUE - ALPHA_ADJUSTMENT)
@Override @SuppressWarnings("MissingPermission") public void onMapReady(GoogleMap googleMap) { map = googleMap; map.getUiSettings().setMapToolbarEnabled(false); if (listener.hasLocationPermission()) { map.setMyLocationEnabled(true); map.getUiSettings().setMyLocationButtonEnabled(false); } map.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() { @Override public void onInfoWindowClick(Marker marker) { if (marker.getTag() instanceof Place) { Place place = (Place) marker.getTag(); listener.onPlaceSelected(place); } } }); if (state == State.MAP) { displayPlaces(placesToDisplay); } }
/** * Updates the map's UI settings based on whether the user has granted location permission. */ private void updateLocationUI() { if (mMap == null) { return; } try { if (mLocationPermissionGranted) { mMap.setMyLocationEnabled(true); mMap.getUiSettings().setMyLocationButtonEnabled(true); } else { mMap.setMyLocationEnabled(false); mMap.getUiSettings().setMyLocationButtonEnabled(false); mLastKnownLocation = null; getLocationPermission(); } } catch (SecurityException e) { Log.e("Exception: %s", e.getMessage()); } } }