renamed LayerGroup _iterateLayers to eachLayer
This commit is contained in:
parent
2df0a4c283
commit
54855494bb
@ -80,6 +80,7 @@ Icon API was improved to be more flexible, but one of the changes is backwards-i
|
||||
* Added `originalEvent` property to `MouseEvent` (by [@k4](https://github.com/k4)). [#521](https://github.com/CloudMade/Leaflet/pull/521)
|
||||
* Added `containerPoint` property to `MouseEvent`. [#413](https://github.com/CloudMade/Leaflet/issues/413)
|
||||
* Added `contextmenu` event to vector layers (by [@ErrorProne](https://github.com/ErrorProne)). [#500](https://github.com/CloudMade/Leaflet/pull/500)
|
||||
* Added `LayerGroup` `eachLayer` method for iterating over its members.
|
||||
* Added `FeatureGroup` `mousemove` and `contextmenu` events (by [@jacobtoye](https://github.com/jacobtoye)). [#816](https://github.com/CloudMade/Leaflet/pull/816)
|
||||
* Added chaining to `DomEvent` methods.
|
||||
* Added `on` and `off` aliases for `DomEvent` `addListener` and `removeListener` methods.
|
||||
|
@ -9,7 +9,7 @@ L.FeatureGroup = L.LayerGroup.extend({
|
||||
if (this._layers[L.Util.stamp(layer)]) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
layer.on('click dblclick mouseover mouseout mousemove contextmenu', this._propagateEvent, this);
|
||||
|
||||
L.LayerGroup.prototype.addLayer.call(this, layer);
|
||||
@ -40,7 +40,7 @@ L.FeatureGroup = L.LayerGroup.extend({
|
||||
|
||||
getBounds: function () {
|
||||
var bounds = new L.LatLngBounds();
|
||||
this._iterateLayers(function (layer) {
|
||||
this.eachLayer(function (layer) {
|
||||
bounds.extend(layer instanceof L.Marker ? layer.getLatLng() : layer.getBounds());
|
||||
}, this);
|
||||
return bounds;
|
||||
@ -56,4 +56,4 @@ L.FeatureGroup = L.LayerGroup.extend({
|
||||
|
||||
L.featureGroup = function (layers) {
|
||||
return new L.FeatureGroup(layers);
|
||||
};
|
||||
};
|
||||
|
@ -40,7 +40,7 @@ L.LayerGroup = L.Class.extend({
|
||||
},
|
||||
|
||||
clearLayers: function () {
|
||||
this._iterateLayers(this.removeLayer, this);
|
||||
this.eachLayer(this.removeLayer, this);
|
||||
return this;
|
||||
},
|
||||
|
||||
@ -63,11 +63,11 @@ L.LayerGroup = L.Class.extend({
|
||||
|
||||
onAdd: function (map) {
|
||||
this._map = map;
|
||||
this._iterateLayers(map.addLayer, map);
|
||||
this.eachLayer(map.addLayer, map);
|
||||
},
|
||||
|
||||
onRemove: function (map) {
|
||||
this._iterateLayers(map.removeLayer, map);
|
||||
this.eachLayer(map.removeLayer, map);
|
||||
this._map = null;
|
||||
},
|
||||
|
||||
@ -76,7 +76,7 @@ L.LayerGroup = L.Class.extend({
|
||||
return this;
|
||||
},
|
||||
|
||||
_iterateLayers: function (method, context) {
|
||||
eachLayer: function (method, context) {
|
||||
for (var i in this._layers) {
|
||||
if (this._layers.hasOwnProperty(i)) {
|
||||
method.call(context, this._layers[i]);
|
||||
@ -87,4 +87,4 @@ L.LayerGroup = L.Class.extend({
|
||||
|
||||
L.layerGroup = function (layers) {
|
||||
return new L.LayerGroup(layers);
|
||||
};
|
||||
};
|
||||
|
@ -14,7 +14,7 @@
|
||||
setLatLngs: function (latlngs) {
|
||||
var i = 0, len = latlngs.length;
|
||||
|
||||
this._iterateLayers(function (layer) {
|
||||
this.eachLayer(function (layer) {
|
||||
if (i < len) {
|
||||
layer.setLatLngs(latlngs[i++]);
|
||||
} else {
|
||||
|
@ -107,10 +107,10 @@ L.Handler.PolyEdit = L.Handler.extend({
|
||||
if (this._poly._latlngs.length < 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var marker = e.target,
|
||||
i = marker._index;
|
||||
|
||||
|
||||
// Check existence of previous and next markers since they wouldn't exist for edge points on the polyline
|
||||
if (marker._prev && marker._next) {
|
||||
this._createMiddleMarker(marker._prev, marker._next);
|
||||
@ -133,7 +133,7 @@ L.Handler.PolyEdit = L.Handler.extend({
|
||||
},
|
||||
|
||||
_updateIndexes: function (index, delta) {
|
||||
this._markerGroup._iterateLayers(function (marker) {
|
||||
this._markerGroup.eachLayer(function (marker) {
|
||||
if (marker._index > index) {
|
||||
marker._index += delta;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user