Google Maps API v3: Can I setZoom after fitBounds?

前端 未结 23 2475
执笔经年
执笔经年 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 09:59

    I use:

    gmap.setZoom(24); //this looks a high enough zoom value
    gmap.fitBounds(bounds); //now the fitBounds should make the zoom value only less
    

    This will use the smaller of 24 and the necessary zoom level according to your code, however it probably changes the zoom anyway and doesn't care about how much you zoomed out.

提交回复
热议问题