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

javascript - What does 'gridSize' define in MarkerClusterer under 'option' object? - Stack Overf

programmeradmin0浏览0评论

I am working on Google Maps and clustering of markers using MarkerClusterer library. What exactly does 'gridSize' parameter define in 'option' object? If it is the size of a cluster image in pixels, then how can I change it for different clusters in the same map?

I have tried using the MarkerClusterer library using the documentation provided at this link:

It doesn't explain how to change and add 'option' object and how can we edit the option code according to our needs.

I would like you to help me with making the cluster image size different for different clusters on the same map.

I am working on Google Maps and clustering of markers using MarkerClusterer library. What exactly does 'gridSize' parameter define in 'option' object? If it is the size of a cluster image in pixels, then how can I change it for different clusters in the same map?

I have tried using the MarkerClusterer library using the documentation provided at this link: https://developers.google./maps/documentation/javascript/marker-clustering

It doesn't explain how to change and add 'option' object and how can we edit the option code according to our needs.

I would like you to help me with making the cluster image size different for different clusters on the same map.

Share Improve this question edited Sep 14, 2019 at 10:54 evan 5,6992 gold badges12 silver badges21 bronze badges asked Sep 9, 2019 at 23:43 Harnam SinghHarnam Singh 841 silver badge6 bronze badges 2
  • from one of the versions of the documentation: gridSize number The grid size of a cluster in pixels. – geocodezip Commented Sep 10, 2019 at 0:11
  • @geocodezip I already visited that link but it doesn't explain in detail and only partially answers my question. – Harnam Singh Commented Sep 10, 2019 at 5:22
Add a ment  | 

1 Answer 1

Reset to default 8

The MarkerClusterer library's reference states:

gridSize - The grid size of a cluster in pixels.

To use this option you can either add it in your MarkerClusterer options upon object creation:

var markerCluster = new MarkerClusterer(map, markers, {
  imagePath: 'https://developers.google./maps/documentation/javascript/examples/markerclusterer/m',
  gridSize: 90
});

Or use the setGridSize method:

markerCluster.setGridSize(90);

And to check the current grid size of your markerCluster use getGridSize.

Hope this helps you.

发布评论

评论列表(0)

  1. 暂无评论