From fa487f5bb76d8753bf9796a8d093232abc83deb4 Mon Sep 17 00:00:00 2001 From: Mike Atlas Date: Wed, 25 Mar 2015 19:18:07 -0400 Subject: [PATCH] polyline styling options - attempt 2 --- README.md | 1 + src/MarkerCluster.Spiderfier.js | 10 +++++++--- src/MarkerClusterGroup.js | 3 +++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 40ec2da00e..a975798e82 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ By default the Clusterer enables some nice defaults for you: * **zoomToBoundsOnClick**: When you click a cluster we zoom to its bounds. * **spiderfyOnMaxZoom**: When you click a cluster at the bottom zoom level we spiderfy it so you can see all of its markers. (*Note: the spiderfy occurs at the current zoom level if all items within the cluster are physically located at the same latitude and longitude.*) * **removeOutsideVisibleBounds**: Clusters and markers too far from the viewport are removed from the map for performance. +* **spiderLegPolylineOptions**: Allows you to specify [PolylineOptions](http://leafletjs.com/reference.html#polyline-options) to style spider legs. By default, they are `{ weight: 1.5, color: '#222' }`. You can disable any of these as you want in the options when you create the MarkerClusterGroup: ```javascript diff --git a/src/MarkerCluster.Spiderfier.js b/src/MarkerCluster.Spiderfier.js index ead03b4ce4..6bf82c6992 100644 --- a/src/MarkerCluster.Spiderfier.js +++ b/src/MarkerCluster.Spiderfier.js @@ -136,8 +136,8 @@ L.MarkerCluster.include(!L.DomUtil.TRANSITION ? { fg.addLayer(m); - - leg = new L.Polyline([this._latlng, newPos], { weight: 1.5, color: '#222' }); + var legOptions = this._group.options.spiderLegPolylineOptions; + leg = new L.Polyline([this._latlng, newPos], legOptions); map.addLayer(leg); m._spiderLeg = leg; } @@ -201,7 +201,11 @@ L.MarkerCluster.include(!L.DomUtil.TRANSITION ? { //Add Legs. - leg = new L.Polyline([me._latlng, newPos], { weight: 1.5, color: '#222', opacity: initialLegOpacity }); + var legOptions = this._group.options.spiderLegPolylineOptions; + if (legOptions.opacity === undefined) { + legOptions.opacity = initialLegOpacity; + } + leg = new L.Polyline([me._latlng, newPos], legOptions); map.addLayer(leg); m._spiderLeg = leg; diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js index c487468b12..e1f566b8f2 100644 --- a/src/MarkerClusterGroup.js +++ b/src/MarkerClusterGroup.js @@ -26,6 +26,9 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ //Increase to increase the distance away that spiderfied markers appear from the center spiderfyDistanceMultiplier: 1, + // Make it possible to specify a polyline options on a spider leg + spiderLegPolylineOptions: { weight: 1.5, color: '#222' }, + // When bulk adding layers, adds markers in chunks. Means addLayers may not add all the layers in the call, others will be loaded during setTimeouts chunkedLoading: false, chunkInterval: 200, // process markers for a maximum of ~ n milliseconds (then trigger the chunkProgress callback)