开发者

Google Maps Api V3: Limit MarkerClusterer on certain zoom levels

I have a MarkerClusterer which i want to disable if the开发者_如何学运维 zoom level is below a threshold.

Example: The zoom level is 10, the clusters are visible. The threshold is 5, so if the user zooms out to see the world, all Markers should not be rendered. I don't want to clear the markers though, because they need to be shown if the user zooms in again.


If you don't want to clear the markers, you can instead use setMap() to set the map, to which the MarkerCluster is assigned, to a different map than the one the user is viewing.

setMap() takes null as a valid parameter.

Another option is to do some awful hack, like creating a second map that is not visible to the user and assigning the MarkerCluster to that map. It won't win any coding competitions, but it will work.

Then, when you get back to an appropriate zoom level, you can use setMap() again to put the MarkerCluster back on the map.

You can use the zoom_changed event to detect when the zoom on the map has changed and call setMap() appropriately.

Hopefully, this is all you need to get this done, but if not, post some of your code and maybe we can try to be more specific about exactly how to modify it to achieve this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜