googlemaps / googlemaps/js-markerclusterer

Help converting old version to the new one please

Open
#230 4 comments 0 reactions 0 assignees View on GitHub
triage me type: question
Dominant language
TypeScript
Stars
293
Forks
104
Avg merge
3m
Merged PRs (30d)
18

Description

First issue is I'm not sure how I can set the zoomOnClick, gridSize, etc in the new version. I am able to get my markers to show though on the map.
```
/*//set marker clusterer
markerCluster = MarkerClusterer(map, markers,
{
zoomOnClick: false,
gridSize: 50,
imagePath: '/assets/img/gmaps/clusterplus/m',
title: 'Multiple Entries'
}
);
*/

//edited 02-19-22 to markerClusterer.MarkerClusterer from markerClusterer (see notes about using the npm downloaded version at https://www.npmjs.com/package/@googlemaps/markerclusterer)
markerCluster = new markerClusterer.MarkerClusterer({ map, markers });
```

Second issue is I don't understand how to use the new 'onClusterClick' way. I was previously using a listener for this which no longer works with the new version. https://googlemaps.github.io/js-markerclusterer/interfaces/MarkerClustererOptions.html goes into the options of the new version and mentions a 'onClusterClick', but I haven't been able to get it to do anything.

```
/*
//no longer works with new version
//marker clusterer click
google.maps.event.addListener(markerCluster, 'clusterclick', function(cluster) {
//close any open windows
infowindow.close();

//if zoom is less than max show just zoom in
if(map.getZoom() < map.maxZoom ){
map.setCenter(cluster.center_);
map.setZoom(map.getZoom() + 2);
}
//show custom window with multiple ip address details
else {
//get markers length
var markersLength = cluster.getMarkers().length;

var detailContent = '' + cluster.getMarkers().length + ' IP Addresses :

'+
'

'+
'
    '+
    //'
  • City : '+cluster.getMarkers()[0].entry_city+'
  • '+
    //'
  • Location : '+cluster.getMarkers()[0].entry_location+'
  • '+
    '
  • City, Location : '+(cluster.getMarkers()[0].entry_city ? cluster.getMarkers()[0].entry_city : 'n/a')+', '+(cluster.getMarkers()[0].entry_location ? cluster.getMarkers()[0].entry_location : 'n/a')+'
  • '+
    '
  • Postal Code : '+cluster.getMarkers()[0].entry_postal+'
  • '+
    '
  • Country : '+cluster.getMarkers()[0].entry_country+'
  • '+
    '
'+
'
'+
'
';

for (var i=0; i < markersLength; i++)
{
detailContent += ''+
'
'+
'
    '+
    '
  • IP Address : '+cluster.getMarkers()[i].entry_ip+'
  • '+
    '
  • Number of entries : '+cluster.getMarkers()[i].entry_total+'
  • '+
    '
'+
'
';
}

var info = new google.maps.MVCObject;
info.set('position', cluster.center_);
infowindow.setContent(detailContent);
infowindow.open(map, info);
}
});
*/
```

Any help or clarification would be appreciated.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.