Google Maps API v3: Can I setZoom after fitBounds?

前端 未结 23 2528
执笔经年
执笔经年 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:57

    If 'bounds_changed' is not firing correctly (sometimes Google doesn't seem to accept coordinates perfectly), then consider using 'center_changed' instead.

    The 'center_changed' event fires every time fitBounds() is called, although it runs immediately and not necessarily after the map has moved.

    In normal cases, 'idle' is still the best event listener, but this may help a couple people running into weird issues with their fitBounds() calls.

    See google maps fitBounds callback

提交回复
热议问题