Setting max zoom level in google maps android api v2

后端 未结 16 2232
无人共我
无人共我 2020-12-02 17:14

I\'m currently working on developing apps by using Google maps android API v2. My code is as follows. Suppose map has several markers and zoom up to show all markers in disp

16条回答
  •  情歌与酒
    2020-12-02 17:44

    I have not found any direct solution in the Google Maps API. A potential solution to this problem consists in listening against the OnCameraChange event: Whenever this event triggers and the zoom level is above the maximum zoom level, it is possible to call animateCamera(). The resulting code would be the following:

    @Override
    public void onCameraChange(CameraPosition position) {
        float maxZoom = 17.0f;
        if (position.zoom > maxZoom)
            map_.animateCamera(CameraUpdateFactory.zoomTo(maxZoom));
    }
    

提交回复
热议问题