When I launch Google maps in Android, it shows the whole world. What do i need to change so as to set the zoom to the marker? Here are the codes. Thanks
googlemap.getUiSettings().setZoomControlsEnabled(true);
googlemap.getUiSettings().setMyLocationButtonEnabled(true);
LatLng cameraLatLng = sfLatLng;
float cameraZoom = 17;
if(savedInstanceState != null){
mapType = savedInstanceState.getInt("map_type", GoogleMap.MAP_TYPE_NORMAL);
double savedLat = savedInstanceState.getDouble("lat");
double savedLng = savedInstanceState.getDouble("lng");
cameraLatLng = new LatLng(savedLat, savedLng);
cameraZoom = savedInstanceState.getFloat("zoom", 30);
googlemap.setMapType(mapType);
googlemap.animateCamera(CameraUpdateFactory.newLatLngZoom(cameraLatLng, cameraZoom));
Users can zoom the map by clicking the zoom controls. They can also zoom and pan by using two-finger movements on the map for touchscreen devices.
When showing a standard Google map, it comes with the default control set: Zoom - displays a slider or "+/-" buttons to control the zoom level of the map.
Google Maps has an integer 'zoom level' which is the resolution of the current view. Zoom levels are between 0 (the entire world can be seen on one map) and 21+. You can also set the minimum and maximum values for the zoom parameter.
you can use zoom variable for zoom level like bellow. Visit Google maps google.com/maps to create map (Step by step: 1) Find location 2) Click the cog symbol in the top left corner and select "Share or embed map" 3) On modal window select "Embed map" 4) Copy iframe code and paste it).
try this---->
map.addMarker(new MarkerOptions().position(latlng)).setVisible(true);
// Move the camera instantly to location with a zoom of 15.
map.moveCamera(CameraUpdateFactory.newLatLngZoom(latlng, 15));
// Zoom in, animating the camera.
map.animateCamera(CameraUpdateFactory.zoomTo(14), 2000, null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With