jawj / OverlappingMarkerSpiderfier

Deals with overlapping markers in Google Maps JS API v3, Google Earth-style
http://blog.mackerron.com
836 stars 238 forks source link

Programmatic click doesn't work with clusterer incorporated #170

Open btbowden opened 4 years ago

btbowden commented 4 years ago

I'm using the spidifier with the marker clusterer plugin and it works great, however there is one problem. I'm activating the marker click programmatically, which does fire the marker event, but doesn't open the info window or spidering as expected.

click event that gets fired: google.maps.event.trigger(localsLocation.Markers[index], 'spider_click');

event code: google.maps.event.addListener(marker, 'spider_click', function (e) { // 'spider_click', not plain 'click' marker.setZIndex(google.maps.Marker.MAX_ZINDEX); localsLocation.infoWindow.setContent("

" + data.Information + "
"); localsLocation.infoWindow.open(localsLocation.Map, marker); });

If I manually click the marker it works as expected though.

btbowden commented 4 years ago

I implemented a time delay on the clusterer constructor and it now works.

        setTimeout(function () {
            // Add a marker clusterer to manage the markers.
            const clusterOptions = {
                imagePath: "/Assets/Images/MarkerClusterer/",
                gridSize: 50,
                maxZoom: 15
            };
            localsLocation.MarkerCluster = new MarkerClusterer(localsLocation.Map, localsLocation.Markers, clusterOptions);
        }, timeout);