limit scrolling and zooming Google Maps Android API v2

后端 未结 6 1204
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-28 10:49

I\'ve added GroundOverlay to map and want to limit scrolling and zooming within this area.

How to limit scrolling within some bounds on android google maps?

6条回答
  •  醉酒成梦
    2020-11-28 11:15

    In maps API v2 there's a Min/MaxZoomLevel on the GoogleMap class, but I don't know if you can set it in any way.

    Another approach would be to add a

    GoogleMap.OnCameraChangeListener
    

    to your map and by implementing

    public void onCameraChange(CameraPosition cameraPosition);
    

    To restrict the visible area, using GoogleMap.moveCamera(cameraPosition)

    That is if you wish the user to be able to scroll or zoom "some".

    You can also totally deactivate the scroll/zoom events via GoogleMapOptions

提交回复
热议问题