Google Maps v2 Set Zoom Level

爱⌒轻易说出口 提交于 2019-12-03 10:14:42

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

The following code may do the trick:

    function addMarker(lat, lng, info) {
    var pt = new google.maps.LatLng(lat, lng);
    bounds.extend(pt);

You can try the following too:

    var pt = new google.maps.LatLng(lat, lng);
    map.setCenter(pt);
    map.setZoom(your desired zoom);

Edit:

 map.moveCamera( CameraUpdateFactory.newLatLngZoom(new LatLng(xxxx,xxxx) , 14.0f) );//where 14.0 is the zoom level
Shuyaib Abdullah
mMap.animateCamera(CameraUpdateFactory.zoomTo(19));

If you have a Place (or bounds), you could zoom to it. E.g. zoom to specific country, city or address with .newLatLngBounds() method:

map.animateCamera(CameraUpdateFactory.newLatLngBounds(place.getViewport(), 10)); // 10 is padding

Zoom level will be selected automatically. It works perfectly with location search.

    private GoogleMap mMap;


   @Override
    public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;
        mMap.setMinZoomPreference(3.0f);
        mMap.setMaxZoomPreference(5.5f);
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!