Set a max zoom level on LatLngBounds builder

前端 未结 10 648
慢半拍i
慢半拍i 2020-12-13 00:57

I haven\'t found an answer in my search, there are a few answers on SO but they didn\'t work for me.

I have 2 markers on the map and I am using LatLngBounds builder

10条回答
  •  余生分开走
    2020-12-13 01:30

    Quick fix is:

    gMap.setOnMapLoadedCallback(this);
    CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
    gMap.setMaxZoomPreference(10);
    gMap.animateCamera(cu);
    
    
    @Override
    public void onMapLoaded() {
        gMap.resetMinMaxZoomPreference();
    }
    

    Beware that it could halt zoom until map is fully reloaded. But as a quick fix it works.

提交回复
热议问题