@Override public void setCenter(LatLngBounds latLngBounds, int boundsPadding) { googleMap.moveCamera(CameraUpdateFactory.newLatLngBounds(latLngBounds, boundsPadding)); }
@Override public void run() { CameraUpdate allTheThings= CameraUpdateFactory.newLatLngBounds(builder.build(), 32); map.moveCamera(allTheThings); } });
private void animateMarker() { map.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 48)); Property<Marker, LatLng> property= Property.of(Marker.class, LatLng.class, "position"); ObjectAnimator animator= ObjectAnimator.ofObject(markerToAnimate, property, new LatLngEvaluator(), nextAnimationEnd); animator.setDuration(2000); animator.start(); if (nextAnimationEnd == LINCOLN_CENTER) { nextAnimationEnd=PENN_STATION; } else { nextAnimationEnd=LINCOLN_CENTER; } }
private void moveCameraToKml(KmlLayer kmlLayer) { //Retrieve the first container in the KML layer KmlContainer container = kmlLayer.getContainers().iterator().next(); //Retrieve a nested container within the first container container = container.getContainers().iterator().next(); //Retrieve the first placemark in the nested container KmlPlacemark placemark = container.getPlacemarks().iterator().next(); //Retrieve a polygon object in a placemark KmlPolygon polygon = (KmlPolygon) placemark.getGeometry(); //Create LatLngBounds of the outer coordinates of the polygon LatLngBounds.Builder builder = new LatLngBounds.Builder(); for (LatLng latLng : polygon.getOuterBoundaryCoordinates()) { builder.include(latLng); } int width = getResources().getDisplayMetrics().widthPixels; int height = getResources().getDisplayMetrics().heightPixels; getMap().moveCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), width, height, 1)); }
@Override public boolean onClusterClick(Cluster<Person> cluster) { // Show a toast with some info when the cluster is clicked. String firstName = cluster.getItems().iterator().next().name; Toast.makeText(this, cluster.getSize() + " (including " + firstName + ")", Toast.LENGTH_SHORT).show(); // Zoom in the cluster. Need to create LatLngBounds and including all the cluster items // inside of bounds, then animate to center of the bounds. // Create the builder to collect all essential cluster items for the bounds. LatLngBounds.Builder builder = LatLngBounds.builder(); for (ClusterItem item : cluster.getItems()) { builder.include(item.getPosition()); } // Get the LatLngBounds final LatLngBounds bounds = builder.build(); // Animate camera to the bounds try { getMap().animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 100)); } catch (Exception e) { e.printStackTrace(); } return true; }
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); } } }
public void moveToAUS(View view) { if (!checkReady()) { return; } mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(AUS, 0)); }
/** * Move the camera to show all of Australia. * Construct a {@link com.google.android.gms.maps.model.LatLngBounds} from markers positions, * then move the camera. */ public void showAustralia(View v) { // Wait until map is ready if (mMap == null) { return; } // Create bounds that include all locations of the map LatLngBounds.Builder boundsBuilder = LatLngBounds.builder() .include(PERTH) .include(ADELAIDE) .include(MELBOURNE) .include(SYDNEY) .include(DARWIN) .include(BRISBANE); // Move camera to show all markers and locations mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(boundsBuilder.build(), 20)); }
@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 onMapReady(GoogleMap map) { mMap = map; // Hide the zoom controls as the button panel will cover it. mMap.getUiSettings().setZoomControlsEnabled(false); // Add lots of markers to the map. addMarkersToMap(); // Setting an info window adapter allows us to change the both the contents and look of the // info window. mMap.setInfoWindowAdapter(new CustomInfoWindowAdapter()); // Set listeners for marker events. See the bottom of this class for their behavior. mMap.setOnMarkerClickListener(this); mMap.setOnInfoWindowClickListener(this); mMap.setOnMarkerDragListener(this); mMap.setOnInfoWindowCloseListener(this); mMap.setOnInfoWindowLongClickListener(this); // Override the default content description on the view, for accessibility mode. // Ideally this string would be localised. mMap.setContentDescription("Map with lots of markers."); LatLngBounds bounds = new LatLngBounds.Builder() .include(PERTH) .include(SYDNEY) .include(ADELAIDE) .include(BRISBANE) .include(MELBOURNE) .include(DARWIN) .build(); mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 50)); }
@Override public CameraUpdate newLatLngBounds(LatLngBounds bounds, int padding) { com.google.android.gms.maps.model.LatLngBounds googleBounds = AnyMapAdapter.adapt(bounds); return new CameraUpdateAdapter( com.google.android.gms.maps.CameraUpdateFactory.newLatLngBounds( googleBounds, padding ) ); }
.include(SYDNEY) .build(); mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 100));
public void animateCamera(final LatLngBounds bounds) { int width = getWidth(); int height = getHeight(); int padding = MapsUtil.DEFAULT_MAP_PADDING; googleMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, width, height, padding)); }
public static void fixZoomForLatLngs(GoogleMap googleMap, List<LatLng> latLngs) { if (latLngs!=null && latLngs.size() > 0) { LatLngBounds.Builder bc = new LatLngBounds.Builder(); for (LatLng latLng: latLngs) { bc.include(latLng); } googleMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bc.build(), 50),4000,null); } }
public static void fixZoomForMarkers(GoogleMap googleMap, List<Marker> markers) { if (markers!=null && markers.size() > 0) { LatLngBounds.Builder bc = new LatLngBounds.Builder(); for (Marker marker : markers) { bc.include(marker.getPosition()); } googleMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bc.build(), 50),4000,null); } }
public void zoomToTwoPoints(LatLng pointA, LatLng pointB) { if ((pointA.latitude != pointB.latitude) && (pointA.longitude != pointB.longitude)) { LatLngBounds.Builder boundsCreator = LatLngBounds.builder(); boundsCreator.include(pointA); boundsCreator.include(pointB); mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(boundsCreator.build(), getResources().getInteger(R.integer.route_zoom_padding))); } }
private static void boundMap(final boolean isListView, final LatLngBounds.Builder builder, final GoogleMap googleMap) { LatLngBounds bounds = builder.build(); googleMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 50)); float zoom = googleMap.getCameraPosition().zoom; if (isListView) googleMap.moveCamera(CameraUpdateFactory.zoomTo(zoom - 1f)); }
public void routeStartAnimation(LatLng northeast, LatLng southwest) { mTracker.send(new HitBuilders.EventBuilder() .setCategory("Action") .setAction("RouteCreated_on_GoogleMap") .build()); LatLngBounds grenzen = new LatLngBounds(southwest, northeast); map.animateCamera(CameraUpdateFactory.newLatLngBounds(grenzen, 100)); listHandler.sendEmptyMessageDelayed(11, 3000); }
private void showBothMarkersAndGetDirections() { if (mOriginMapMarker != null && mDestinationMarker != null) { int width = getResources().getDisplayMetrics().widthPixels; int padding = (int) (width * 0.10); // CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(getLatLngBoundsForMarkers(), padding); mMap.moveCamera(cu); mMap.animateCamera(cu); sendRequest(mOriginMapMarker.getPosition(), mDestinationMarker.getPosition()); } else { } }
@Override public void onMapReady(final GoogleMap googleMap) { googleMap.moveCamera(CameraUpdateFactory.newLatLngBounds( mapLatLngBounds, MapsUtil.calculateWidth(getWindowManager()), MapsUtil.calculateHeight(getWindowManager(), getResources().getDimensionPixelSize(R.dimen.map_margin_bottom)), 150)); googleMap.setOnMapLoadedCallback(() -> googleMap.snapshot(presenter::saveBitmap)); }