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

Spiderfy with custom markers ( OverlayView ) #137

Open crerem opened 7 years ago

crerem commented 7 years ago

Hi, I'm trying to make the spiderfy to work with custom markers ( with regular markers works perfectly - thank you for that.) the custom markers are created via OverlayView CustomMarker.prototype = new google.maps.OverlayView(); and there is a function for draw,remove, getPosition,setPosition,getDraggable,getVisible,getZIndex etc ...

the spiderfy code looks like this (works perfectly on normal markers)

  oms = new OverlappingMarkerSpiderfier(map, 
            {
                markersWontMove: true, 
                markersWontHide: true,
                keepSpiderfied :true,
                legWeight:3
            });
        setOms(gmarkers);

function setOms(gmarkers){
    console.log('setOms');
    for (var i = 0; i < gmarkers.length; i++) {
        if(typeof oms !== 'undefined'){
           oms.addMarker(gmarkers[i]);
        }else{

        }
    }

}

When i click to spiderfy on overlay markers nothing happens - also no errors on console. I assume that some method or marker property is not defined but i cannot figure what i'm doing wrong.

Also this is the method for setPosition

  CustomMarker.prototype.setPosition = function(newlatlng) {
            console.log(this.zIndex+' set pos'+ newlatlng);
            this.latlng=newlatlng;  
    };

on console log i get

click oms.min.js?ver=1.0:540 spiderfy CustomGoogleMapMarker.js?ver=1.0:111 100 set pos(40.719857292886495, -73.9497709243422) oms.min.js?ver=1.0:540 spiderfy CustomGoogleMapMarker.js?ver=1.0:111 100 set pos(40.72366720339454, -73.95847797705767) oms.min.js?ver=1.0:569 unspiderfy CustomGoogleMapMarker.js?ver=1.0:111 1020332 set pos(40.7217622754, -73.95412445069996) oms.min.js?ver=1.0:569 unspiderfy CustomGoogleMapMarker.js?ver=1.0:111 1020318 set pos(40.7217622754, -73.95412445069996)

which looks like the script is spiderfy and then unspirdefy immediately. So i think i need to set some condition that will prevent the unspiderfy . Can you point me in the right direction ?

Thank you

purethemes commented 5 years ago

HI @crerem did you manage to find a solution for this problem? I'm also struggling with it now

mrorigo commented 4 years ago

Same problems over here. Not sure if its meant to work with OverlayView markers at all. Please advise.