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
1 Answer
Reset to default 8The 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.