Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps v2 Set Zoom Level

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));
like image 957
Muli Avatar asked Jun 08 '13 09:06

Muli


People also ask

How do I change the zoom level on Google Maps?

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.

How do I control the zoom on Google Maps?

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.

What are Google Maps zoom levels?

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.

How do I change the zoom level in Google Maps iframe?

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).


1 Answers

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);
like image 62
Mr Roshan Pawar Avatar answered Oct 11 '22 04:10

Mr Roshan Pawar