OverlappingMarkerSpiderfier icon indicating copy to clipboard operation
OverlappingMarkerSpiderfier copied to clipboard

Spiderfy with custom markers ( OverlayView )

Open crerem opened this issue 7 years ago • 2 comments

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

crerem avatar Aug 04 '17 12:08 crerem

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

purethemes avatar Dec 05 '18 13:12 purethemes

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

mrorigo avatar Nov 21 '19 13:11 mrorigo