limit scrolling and zooming Google Maps Android API v2

后端 未结 6 1187
佛祖请我去吃肉
佛祖请我去吃肉 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:24

    Instead of using new and shiny push technology which is onCameraChange, you may try to use old poll technology: map.getCameraPosition() or map.getProjection().getVisibleRegion(). You can then check if returned value is what you like and if not, map.moveCamera(...).

    Basically you need a Handler, which will get the value of camera position in handleMessage and you send messages to this handler every 10ms or so. Inside handleMessage do sendEmptyMessageDelayed.

    You can also use Runnable instead of Message (but that's a matter of taste).

提交回复
热议问题