Properly clear marker if it changes layers.

to address Issue #85
This commit is contained in:
Dave Conway-Jones 2019-03-31 17:43:35 +01:00
parent c8e472fb82
commit c202e80ec1
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4

View File

@ -930,7 +930,7 @@ function setMarker(data) {
delMarker(data.name);
return;
}
data = allData[data.name] = Object.assign(allData[data.name] || {}, data);
delete data.action;
var ll;
var lli = null;
var opt = {};
@ -957,6 +957,7 @@ function setMarker(data) {
map.addLayer(layers["buildings"]);
return;
}
var lay = data.layer || "unknown";
if (typeof layers[lay] == "undefined") { // add layer if if doesn't exist
if (clusterAt > 0) {
@ -979,9 +980,14 @@ function setMarker(data) {
}
if (typeof markers[data.name] != "undefined") {
if (markers[data.name].lay !== data.layer) {
delMarker(data.name);
}
else {
try {layers[lay].removeLayer(markers[data.name]); }
catch(e) { console.log("OOPS"); }
}
}
if (typeof polygons[data.name] != "undefined") { layers[lay].removeLayer(polygons[data.name]); }
if (data.hasOwnProperty("line") && Array.isArray(data.line)) {
@ -1048,11 +1054,16 @@ function setMarker(data) {
else if (data.hasOwnProperty("latitude") && data.hasOwnProperty("longitude") && data.hasOwnProperty("intensity")) { lli = new L.LatLng((data.latitude*1), (data.longitude*1), (data.intensity*1)); }
else { lli = ll }
var words="";
// if (!allData.hasOwnProperty(data.name)) { allData[data.name] = {}; }
// var foo = Object.assign(allData[data.name], data);
// allData[data.name] = foo;
// data = foo;
// console.log("A1",foo,allData);
// Create the icons... handle plane, car, ship, wind, earthquake as specials
var marker, myMarker;
var icon, q;
var words="";
var labelOffset = [20,-8];
var drag = false;
if (data.draggable === true) { drag = true; }