Skip to content

Commit bb92b17

Browse files
committed
Add options.spiderfyDistanceMultiplier, allows making spiderfied markers go futher away. Fixes #100
1 parent 290df23 commit bb92b17

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/MarkerCluster.Spiderfier.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ L.MarkerCluster.include({
5151
},
5252

5353
_generatePointsCircle: function (count, centerPt) {
54-
var circumference = this._circleFootSeparation * (2 + count),
54+
var circumference = this._group.options.spiderfyDistanceMultiplier * this._circleFootSeparation * (2 + count),
5555
legLength = circumference / this._2PI, //radius from circumference
5656
angleStep = this._2PI / count,
5757
res = [],
@@ -68,17 +68,19 @@ L.MarkerCluster.include({
6868
},
6969

7070
_generatePointsSpiral: function (count, centerPt) {
71-
var legLength = this._spiralLengthStart,
71+
var legLength = this._group.options.spiderfyDistanceMultiplier * this._spiralLengthStart,
72+
separation = this._group.options.spiderfyDistanceMultiplier * this._spiralFootSeparation,
73+
lengthFactor = this._group.options.spiderfyDistanceMultiplier * this._spiralLengthFactor,
7274
angle = 0,
7375
res = [],
7476
i;
7577

7678
res.length = count;
7779

7880
for (i = count - 1; i >= 0; i--) {
79-
angle += this._spiralFootSeparation / legLength + i * 0.0005;
81+
angle += separation / legLength + i * 0.0005;
8082
res[i] = new L.Point(centerPt.x + legLength * Math.cos(angle), centerPt.y + legLength * Math.sin(angle))._round();
81-
legLength += this._2PI * this._spiralLengthFactor / angle;
83+
legLength += this._2PI * lengthFactor / angle;
8284
}
8385
return res;
8486
}

src/MarkerClusterGroup.js

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
2020
// If you are adding individual markers set to true, if adding bulk markers leave false for massive performance gains.
2121
animateAddingMarkers: false,
2222

23+
//Increase to increase the distance away that spiderfied markers appear from the center
24+
spiderfyDistanceMultiplier: 1,
25+
2326
//Options to pass to the L.Polygon constructor
2427
polygonOptions: {}
2528
},

0 commit comments

Comments
 (0)