[layer-count] Use LayerGroup.eachLayer instead of LayerGroup._layers
This commit is contained in:
@ -32,24 +32,21 @@ plugin.layerCount.onBtnClick = function(ev) {
|
|||||||
|
|
||||||
if(btn.classList.contains("active")) {
|
if(btn.classList.contains("active")) {
|
||||||
if(window.plugin.drawTools !== undefined) {
|
if(window.plugin.drawTools !== undefined) {
|
||||||
for (var layerId in window.plugin.drawTools.drawnItems._layers) {
|
window.plugin.drawTools.drawnItems.eachLayer(function(layer) {
|
||||||
var layer = window.plugin.drawTools.drawnItems._layers[layerId];
|
|
||||||
if (layer instanceof L.GeodesicPolygon) {
|
if (layer instanceof L.GeodesicPolygon) {
|
||||||
L.DomUtil.addClass(layer._path, "leaflet-clickable");
|
L.DomUtil.addClass(layer._path, "leaflet-clickable");
|
||||||
layer._path.setAttribute("pointer-events", layer.options.pointerEventsBackup);
|
layer._path.setAttribute("pointer-events", layer.options.pointerEventsBackup);
|
||||||
layer.options.pointerEvents = layer.options.pointerEventsBackup;
|
layer.options.pointerEvents = layer.options.pointerEventsBackup;
|
||||||
layer.options.clickable = true;
|
layer.options.clickable = true;
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
map.off("click", plugin.layerCount.calculate);
|
map.off("click", plugin.layerCount.calculate);
|
||||||
btn.classList.remove("active");
|
btn.classList.remove("active");
|
||||||
} else {
|
} else {
|
||||||
console.log("inactive");
|
console.log("inactive");
|
||||||
if(window.plugin.drawTools !== undefined) {
|
if(window.plugin.drawTools !== undefined) {
|
||||||
for (var layerId in window.plugin.drawTools.drawnItems._layers) {
|
window.plugin.drawTools.drawnItems.eachLayer(function(layer) {
|
||||||
var layer = window.plugin.drawTools.drawnItems._layers[layerId];
|
|
||||||
if (layer instanceof L.GeodesicPolygon) {
|
if (layer instanceof L.GeodesicPolygon) {
|
||||||
layer.options.pointerEventsBackup = layer.options.pointerEvents;
|
layer.options.pointerEventsBackup = layer.options.pointerEvents;
|
||||||
layer.options.pointerEvents = null;
|
layer.options.pointerEvents = null;
|
||||||
@ -57,8 +54,7 @@ plugin.layerCount.onBtnClick = function(ev) {
|
|||||||
L.DomUtil.removeClass(layer._path, "leaflet-clickable");
|
L.DomUtil.removeClass(layer._path, "leaflet-clickable");
|
||||||
layer._path.setAttribute("pointer-events", "none");
|
layer._path.setAttribute("pointer-events", "none");
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
map.on("click", plugin.layerCount.calculate);
|
map.on("click", plugin.layerCount.calculate);
|
||||||
btn.classList.add("active");
|
btn.classList.add("active");
|
||||||
@ -115,8 +111,8 @@ plugin.layerCount.calculate = function(ev) {
|
|||||||
for(var guid in fields) {
|
for(var guid in fields) {
|
||||||
var field = fields[guid];
|
var field = fields[guid];
|
||||||
|
|
||||||
// we don't need to check the field's bounds first. pnpoly is pretty simple math. the bounds is about 50 times
|
// we don't need to check the field's bounds first. pnpoly is pretty simple math.
|
||||||
// slower than just using pnpoly
|
// Checking the bounds is about 50 times slower than just using pnpoly
|
||||||
if(plugin.layerCount.pnpoly(field._latlngs, point)) {
|
if(plugin.layerCount.pnpoly(field._latlngs, point)) {
|
||||||
if(field.options.team == TEAM_ENL)
|
if(field.options.team == TEAM_ENL)
|
||||||
layersEnl++;
|
layersEnl++;
|
||||||
@ -143,7 +139,7 @@ plugin.layerCount.calculate = function(ev) {
|
|||||||
var content = "No fields";
|
var content = "No fields";
|
||||||
|
|
||||||
if (layersDrawn != 0)
|
if (layersDrawn != 0)
|
||||||
content += "; draw: " + layersDrawn + " field(s)";
|
content += "; draw: " + layersDrawn + " polygon(s)";
|
||||||
|
|
||||||
plugin.layerCount.tooltip.innerHTML = content;
|
plugin.layerCount.tooltip.innerHTML = content;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user