Google Maps API v3: Can I setZoom after fitBounds?

前端 未结 23 2531
执笔经年
执笔经年 2020-11-27 09:35

I have a set of points I want to plot on an embedded Google Map (API v3). I\'d like the bounds to accommodate all points unless the zoom level is too low (i.e., zoomed out

23条回答
  •  伪装坚强ぢ
    2020-11-27 10:03

    I don't like to suggest it, but if you must try - first call

    gmap.fitBounds(bounds);

    Then create a new Thread/AsyncTask, have it sleep for 20-50ms or so and then call

    gmap.setZoom( Math.max(6, gmap.getZoom()) );

    from the UI thread (use a handler or the onPostExecute method for AsyncTask).

    I don't know if it works, just a suggestion. Other than that you'd have to somehow calculate the zoom level from your points yourself, check if it's too low, correct it and then just call gmap.setZoom(correctedZoom)

提交回复
热议问题