最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - @googlemapsmarkerclusterer: How to set maxZoom? - Stack Overflow

programmeradmin0浏览0评论

I'm trying to figure out how to set the maxZoom attribute.

I found the list of acceptable arguments:

new MarkerClusterer({ map, markers, algorithm, renderer, onClusterClick })

So, I don't want to implement my own algorithm. The default one I guess pretty cool.

I found the maxZoom property in the documentation. But cannot understand how to pass it to the MarkerClusterer object.

I saw this question, but looks like the MarkerClusterer implementation have changed and the answer is outdated. The MarkerClusterer object accepts only one argument with described fields above for now.

I'll be very grateful for any help.

I'm trying to figure out how to set the maxZoom attribute.

I found the list of acceptable arguments:

new MarkerClusterer({ map, markers, algorithm, renderer, onClusterClick })

So, I don't want to implement my own algorithm. The default one I guess pretty cool.

I found the maxZoom property in the documentation. But cannot understand how to pass it to the MarkerClusterer object.

I saw this question, but looks like the MarkerClusterer implementation have changed and the answer is outdated. The MarkerClusterer object accepts only one argument with described fields above for now.

I'll be very grateful for any help.

Share Improve this question edited Nov 11, 2022 at 19:37 Alexey Zalyotov asked Nov 11, 2022 at 16:09 Alexey ZalyotovAlexey Zalyotov 4942 gold badges7 silver badges20 bronze badges 2
  • 3 What a terrible/annoying/unclear documentation. Does this help? github./googlemaps/js-markerclusterer/issues/374 - if it doesn't, I'd require clarification on the github issues page. – MrUpsidown Commented Nov 29, 2022 at 10:28
  • 1 The documentation is indeed absolutely horrible. Happy to see I'm not alone, and you provided an answer below :) – pancakecoder Commented Aug 4, 2023 at 9:10
Add a ment  | 

2 Answers 2

Reset to default 7

Thanks to @mrupsidown for help! The correct way to set custom maxZoom is to change the algorithm:

const algorithm = new SuperClusterAlgorithm({ maxZoom: 12 })
new MarkerClusterer({map, markers, algorithm, renderer, onClusterClick});

I was stuck on this as well and found an easier solution. You just need to pass an object algorithmOptions.

new MarkerClusterer({map, markers, algorithmOptions: { maxZoom: 10 }});

I also didn't understand the docs properly but found it by looking into the source code: https://github./googlemaps/js-markerclusterer/blob/e3ea80c1172eedc0f9784d832f419153a49825ce/src/markerclusterer.ts#L84C8-L84C8

发布评论

评论列表(0)

  1. 暂无评论