avoid unnecessary unkown layer enable

This commit is contained in:
Dave Conway-Jones 2019-04-02 10:28:26 +01:00
parent ad992245be
commit 13b2dc0e04
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4

View File

@ -930,7 +930,6 @@ function setMarker(data) {
delMarker(data.name); delMarker(data.name);
return; return;
} }
delete data.action;
var ll; var ll;
var lli = null; var lli = null;
var opt = {}; var opt = {};
@ -959,25 +958,28 @@ function setMarker(data) {
} }
var lay = data.layer || "unknown"; var lay = data.layer || "unknown";
if (typeof layers[lay] == "undefined") { // add layer if if doesn't exist if (data.hasOwnProperty("action") && data.action.indexOf("layer") === -1) {
if (clusterAt > 0) { if (typeof layers[lay] == "undefined") { // add layer if if doesn't exist
layers[lay] = new L.MarkerClusterGroup({ if (clusterAt > 0) {
maxClusterRadius:50, layers[lay] = new L.MarkerClusterGroup({
spiderfyDistanceMultiplier:1.8, maxClusterRadius:50,
disableClusteringAtZoom:clusterAt spiderfyDistanceMultiplier:1.8,
//zoomToBoundsOnClick:false disableClusteringAtZoom:clusterAt
}); //zoomToBoundsOnClick:false
});
}
else {
layers[lay] = new L.LayerGroup();
}
overlays[lay] = layers[lay];
if (showLayerMenu !== false) {
layercontrol.addOverlay(layers[lay],lay);
}
map.addLayer(overlays[lay]);
//console.log("ADDED LAYER",lay,layers);
} }
else {
layers[lay] = new L.LayerGroup();
}
overlays[lay] = layers[lay];
if (showLayerMenu !== false) {
layercontrol.addOverlay(layers[lay],lay);
}
map.addLayer(overlays[lay]);
//console.log("ADDED LAYER",lay,layers);
} }
delete data.action;
if (typeof markers[data.name] != "undefined") { if (typeof markers[data.name] != "undefined") {
if (markers[data.name].lay !== data.layer) { if (markers[data.name].lay !== data.layer) {
@ -1034,7 +1036,6 @@ function setMarker(data) {
layers[lay].addLayer(polycirc); layers[lay].addLayer(polycirc);
} }
} }
//console.log("handling",data.name);
if (typeof data.coordinates == "object") { ll = new L.LatLng(data.coordinates[1],data.coordinates[0]); } if (typeof data.coordinates == "object") { ll = new L.LatLng(data.coordinates[1],data.coordinates[0]); }
else if (data.hasOwnProperty("position") && data.position.hasOwnProperty("lat") && data.position.hasOwnProperty("lon")) { else if (data.hasOwnProperty("position") && data.position.hasOwnProperty("lat") && data.position.hasOwnProperty("lon")) {
data.lat = data.position.lat*1; data.lat = data.position.lat*1;