Do not move binded circles when using OverlappingMarkerSpiderfier

45 Views Asked by At

I decided to use OverlappingMarkerSpiderfier when having multiple markers on the same place or very close each other.

The problem was that in my scope each marker has binded marker which move when spiderfy is triggered.

1

There are 1 best solutions below

0
On

Basically the solution is to add listeners and manualy ensure that the circles are kept in places.

this.oms.addListener('spiderfy', function (activeMarkers) {
    activeMarkers.forEach(function(marker) {
        console.log(marker._originalPosition);
        marker._circle.unbind('center');
        marker._circle.setCenter(marker._originalPosition);
    });
});
this.oms.addListener('unspiderfy', function (activeMarkers) {
    activeMarkers.forEach(function(marker) {
        circle.bindTo('center', marker, 'position');
    });
});

Where you have to store _originalPosition in advance as original location is not available from the _omsData (see the issue).