[Pkg-javascript-commits] [leaflet-markercluster] 07/219: Update build
Jonas Smedegaard
dr at jones.dk
Sat May 7 09:39:06 UTC 2016
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository leaflet-markercluster.
commit c1d4a8872838d7285a73713d4cd4b1116c24a82b
Author: danzel <danzel at localhost.geek.nz>
Date: Fri Dec 20 10:04:11 2013 +1300
Update build
---
dist/leaflet.markercluster-src.js | 131 ++++++++++++++++++++------------------
dist/leaflet.markercluster.js | 2 +-
2 files changed, 71 insertions(+), 62 deletions(-)
diff --git a/dist/leaflet.markercluster-src.js b/dist/leaflet.markercluster-src.js
index 0000fb3..2993348 100644
--- a/dist/leaflet.markercluster-src.js
+++ b/dist/leaflet.markercluster-src.js
@@ -32,6 +32,10 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
//Increase to increase the distance away that spiderfied markers appear from the center
spiderfyDistanceMultiplier: 1,
+ //When bulk adding layers, runs chunks at a time. Means addLayers may not add all the layers in the call, others will be loaded during setTimeouts
+ chunkedLoading: false,
+ chunkSize: 500,
+
//Options to pass to the L.Polygon constructor
polygonOptions: {}
},
@@ -158,52 +162,76 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
//Takes an array of markers and adds them in bulk
addLayers: function (layersArray) {
- var i, l, m,
- onMap = this._map,
- fg = this._featureGroup,
- npg = this._nonPointGroup;
+ var fg = this._featureGroup,
+ npg = this._nonPointGroup,
+ chunkSize = this.options.chunkSize,
+ newMarkers, i, l, m;
- for (i = 0, l = layersArray.length; i < l; i++) {
- m = layersArray[i];
+ if (this._map) {
+ var start = 0;
+ var end = this.options.chunkedLoading && chunkSize < layersArray.length ? chunkSize : layersArray.length;
+ var process = L.bind(function () {
+ for (i = start; i < end; i++) {
+ m = layersArray[i];
+
+ //Not point data, can't be clustered
+ if (!m.getLatLng) {
+ npg.addLayer(m);
+ continue;
+ }
- //Not point data, can't be clustered
- if (!m.getLatLng) {
- npg.addLayer(m);
- continue;
- }
+ if (this.hasLayer(m)) {
+ continue;
+ }
- if (this.hasLayer(m)) {
- continue;
- }
+ this._addLayer(m, this._maxZoom);
- if (!onMap) {
- this._needsClustering.push(m);
- continue;
- }
+ //If we just made a cluster of size 2 then we need to remove the other marker from the map (if it is) or we never will
+ if (m.__parent) {
+ if (m.__parent.getChildCount() === 2) {
+ var markers = m.__parent.getAllChildMarkers(),
+ otherMarker = markers[0] === m ? markers[1] : markers[0];
+ fg.removeLayer(otherMarker);
+ }
+ }
+ }
- this._addLayer(m, this._maxZoom);
+ if (end === layersArray.length) {
+ //Update the icons of all those visible clusters that were affected
+ this._featureGroup.eachLayer(function (c) {
+ if (c instanceof L.MarkerCluster && c._iconNeedsUpdate) {
+ c._updateIcon();
+ }
+ });
- //If we just made a cluster of size 2 then we need to remove the other marker from the map (if it is) or we never will
- if (m.__parent) {
- if (m.__parent.getChildCount() === 2) {
- var markers = m.__parent.getAllChildMarkers(),
- otherMarker = markers[0] === m ? markers[1] : markers[0];
- fg.removeLayer(otherMarker);
+ this._topClusterLevel._recursivelyAddChildrenToMap(null, this._zoom, this._currentShownBounds);
+ } else {
+ start = end;
+ end = Math.min(end + chunkSize, layersArray.length);
+ setTimeout(process, 0);
}
- }
- }
+ }, this);
+
+ process();
+ } else {
+ newMarkers = [];
+ for (i = 0, l = layersArray.length; i < l; i++) {
+ m = layersArray[i];
- if (onMap) {
- //Update the icons of all those visible clusters that were affected
- fg.eachLayer(function (c) {
- if (c instanceof L.MarkerCluster && c._iconNeedsUpdate) {
- c._updateIcon();
+ //Not point data, can't be clustered
+ if (!m.getLatLng) {
+ npg.addLayer(m);
+ continue;
}
- });
- this._topClusterLevel._recursivelyAddChildrenToMap(null, this._zoom, this._currentShownBounds);
- }
+ if (this.hasLayer(m)) {
+ continue;
+ }
+ newMarkers.push(m);
+ }
+ this._needsClustering = this._needsClustering.concat(newMarkers);
+ }
return this;
},
@@ -419,23 +447,9 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
}
this._needsRemoving = [];
- for (i = 0, l = this._needsClustering.length; i < l; i++) {
- layer = this._needsClustering[i];
-
- //If the layer doesn't have a getLatLng then we can't cluster it, so add it to our child featureGroup
- if (!layer.getLatLng) {
- this._featureGroup.addLayer(layer);
- continue;
- }
-
-
- if (layer.__parent) {
- continue;
- }
- this._addLayer(layer, this._maxZoom);
- }
- this._needsClustering = [];
-
+ //Remember the current zoom level and bounds
+ this._zoom = this._map.getZoom();
+ this._currentShownBounds = this._getExpandedVisibleBounds();
this._map.on('zoomend', this._zoomEnd, this);
this._map.on('moveend', this._moveEnd, this);
@@ -446,15 +460,10 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
this._bindEvents();
-
//Actually add our markers to the map:
-
- //Remember the current zoom level and bounds
- this._zoom = this._map.getZoom();
- this._currentShownBounds = this._getExpandedVisibleBounds();
-
- //Make things appear on the map
- this._topClusterLevel._recursivelyAddChildrenToMap(null, this._zoom, this._currentShownBounds);
+ l = this._needsClustering;
+ this._needsClustering = [];
+ this.addLayers(l);
},
//Overrides FeatureGroup.onRemove
@@ -632,7 +641,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
e.layer.zoomToBounds();
}
- // Focus the map again for keyboard users.
+ // Focus the map again for keyboard users.
if (e.originalEvent && e.originalEvent.keyCode === 13) {
map._container.focus();
}
diff --git a/dist/leaflet.markercluster.js b/dist/leaflet.markercluster.js
index 11b1128..3ff065f 100644
--- a/dist/leaflet.markercluster.js
+++ b/dist/leaflet.markercluster.js
@@ -3,4 +3,4 @@
https://github.com/Leaflet/Leaflet.markercluster
(c) 2012-2013, Dave Leaver, smartrak
*/
-!function(t,e){L.MarkerClusterGroup=L.FeatureGroup.extend({options:{maxClusterRadius:80,iconCreateFunction:null,spiderfyOnMaxZoom:!0,showCoverageOnHover:!0,zoomToBoundsOnClick:!0,singleMarkerMode:!1,disableClusteringAtZoom:null,removeOutsideVisibleBounds:!0,animateAddingMarkers:!1,spiderfyDistanceMultiplier:1,polygonOptions:{}},initialize:function(t){L.Util.setOptions(this,t),this.options.iconCreateFunction||(this.options.iconCreateFunction=this._defaultIconCreateFunction),this._featureG [...]
\ No newline at end of file
+!function(t,e){L.MarkerClusterGroup=L.FeatureGroup.extend({options:{maxClusterRadius:80,iconCreateFunction:null,spiderfyOnMaxZoom:!0,showCoverageOnHover:!0,zoomToBoundsOnClick:!0,singleMarkerMode:!1,disableClusteringAtZoom:null,removeOutsideVisibleBounds:!0,animateAddingMarkers:!1,spiderfyDistanceMultiplier:1,chunkedLoading:!1,chunkSize:500,polygonOptions:{}},initialize:function(t){L.Util.setOptions(this,t),this.options.iconCreateFunction||(this.options.iconCreateFunction=this._defaultIc [...]
\ No newline at end of file
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/leaflet-markercluster.git
More information about the Pkg-javascript-commits
mailing list