Search code examples
javascriptgoogle-mapsoffsetoverlappingmarkerspiderfier

OverlappingMarkerSpiderfier offset length for markers


Background
I use google maps together with clustermarkererplus to display various markertypes with infobubbles on a map. To deal with markers with exactly the same coordinate (or very close) an offset is generated for the markers that overlap by using OverlappingMarkerSpiderfier (OMS). Searching for an answer to this has so far only led me to adjustment of the thickness of the offset lines.

Problem
When there are many markers the offset given by the OMS is too small.

Questions

  • How can I increase the offset (leg length)?
  • Can it be dependent on if the number of markers separated by the OMS is more than a certain value?

Example (to show the effect)
Visualisation of what I want to do, increase offset (leg length)

Code
Documentation of OMS is available at: https://github.com/jawj/OverlappingMarkerSpiderfier //Options I use
options = {keepSpiderfied:true};

//Creation of the OMS
new OverlappingMarkerSpiderfier(map, options);

//Click listener
oms.addListener('click', function(marker, event) {
//Code for showing infowindows
});

//Adding marker
oms.addMarker(marker);


Solution

  • OverlappingMarkerSpiderfier has adjustable offset (leg length) by specifying two different options:

    1. circleFootSeparation: "default:23" (Offset from the center of the circle)
    2. spiralLengthFactor:"default:4" (Value proportional to the offset from the spiral center)

    Angular separation can also be adjusted for the spiral
    spiralFootSeparation:"default:26"