diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3c25232..ae4d892 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,6 @@
### Change Log for Node-RED Worldmap
+ - v1.2.0 - Bump version (should have done it for adding velocity layer). Tidy up deletion of marker and tracks.
- v1.1.16 - Add Velocity layer - for velocity grid type overlays (eg wind, currents, etc)
- v1.1.15 - Tidy of Info, Readme and NATO symbol options.
- v1.1.14 - Add proper NATO symbology via milsymbol.js
diff --git a/README.md b/README.md
index 5bfc047..a2b38a8 100644
--- a/README.md
+++ b/README.md
@@ -9,6 +9,7 @@ map web page for plotting "things" on.
### Updates
+- v1.2.0 - Bump version (should have done it for adding velocity layer). Tidy up deletion of marker and tracks.
- v1.1.16 - Add Velocity layer - for velocity grid type overlays (eg wind, currrents, etc)
- v1.1.15 - Tidy of Info, Readme and NATO symbol options.
- v1.1.14 - Add proper NATO symbology via milsymbol.js
diff --git a/package.json b/package.json
index c670bd7..42ad2ff 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-web-worldmap",
- "version": "1.1.16",
+ "version": "1.2.0",
"description": "A Node-RED node to provide a web page of a world map for plotting things on.",
"dependencies": {
"cgi": "0.3.1",
diff --git a/worldmap.js b/worldmap.js
index 579ed34..4b015b4 100644
--- a/worldmap.js
+++ b/worldmap.js
@@ -140,7 +140,7 @@ module.exports = function(RED) {
var newmsg = RED.util.cloneMessage(msg);
if (msg.payload.deleted) {
delete node.pointsarray[msg.payload.name];
- newmsg.payload.name = msg.payload.name + "_";
+ //newmsg.payload.name = msg.payload.name + "_";
node.send(newmsg); // send the track to be deleted
return;
}
diff --git a/worldmap/index.html b/worldmap/index.html
index 0b60426..926d640 100644
--- a/worldmap/index.html
+++ b/worldmap/index.html
@@ -202,7 +202,7 @@ if ( window.localStorage.hasOwnProperty("maxage") ) {
// Create the Initial Map object.
map = new L.map('map').setView(startpos, startzoom);
-var menuButton = L.easyButton( 'fa-bars fa-lg', function() { toggleMenu(); }, "Toggle menu", "topright").addTo(map);
+var menuButton = L.easyButton( 'fa-bars fa-lg', function() { toggleMenu(); }, "Toggle menu", "topright");
// Move some bits around if in an iframe
if (window.self !== window.top) {
@@ -252,7 +252,7 @@ if (!inIframe) {
heat.setLatLngs([]);
}, "Clears the current heatmap", "bottomright");
}
-//else { if (showUserMenu) { menuButton.addTo(map); } }
+else { if (showUserMenu) { menuButton.addTo(map); } }
// Handle the dialog for popup help
var dialog = document.querySelector('dialog');
@@ -429,7 +429,6 @@ map.on('overlayadd', function(e) {
map.addControl(drawControl);
overlays["drawing"].bringToFront();
}
- //else { console.log("layer add :",e.name); }
ws.send(JSON.stringify({action:"addlayer", name:e.name}));
});
@@ -496,7 +495,7 @@ var rightmenuMap = L.popup().setContent("University of Heidelberg — Map data © OpenStreetMap'
-});
-basemaps["Mapsurfer"] = OpenMapSurfer_Roads;
+// var OpenMapSurfer_Roads = L.tileLayer('http://korona.geog.uni-heidelberg.de/tiles/roads/x={x}&y={y}&z={z}', {
+// maxZoom: 18,
+// attribution: 'Imagery from University of Heidelberg — Map data © OpenStreetMap'
+// });
+// basemaps["Mapsurfer"] = OpenMapSurfer_Roads;
// var MapQuestOpen_OSM = L.tileLayer('http://otile{s}.mqcdn.com/tiles/1.0.0/{type}/{z}/{x}/{y}.{ext}', {
// type: 'map',
@@ -636,13 +635,11 @@ basemaps["UK OS 1919-47"] = NLS_OS_1919_1947;
//});
//basemaps["CartoDB Light"] = CartoPos;
-// Terrain map of US only
-var usterrainmap = new L.StamenTileLayer('terrain');
-basemaps["US terrain"] = usterrainmap;
+// Terrain map by Stamen Design
+basemaps["Terrain"] = new L.StamenTileLayer('terrain');
// Nice watercolour based maps by Stamen Design
-var watermap = new L.StamenTileLayer('watercolor');
-basemaps["Watercolor"] = watermap;
+basemaps["Watercolor"] = new L.StamenTileLayer('watercolor');
// Now add the overlays
@@ -718,23 +715,26 @@ else { showLayerMenu = false;}
// Delete a marker (and notify websocket)
var delMarker = function(dname) {
- //console.log("Deleting",dname);
if (typeof polygons[dname] != "undefined") {
layers[polygons[dname].lay].removeLayer(polygons[dname]);
- ws.send(JSON.stringify({action:"delete", name:dname}));
delete polygons[dname];
}
+ if (typeof polygons[dname+"_"] != "undefined") {
+ layers[polygons[dname+"_"].lay].removeLayer(polygons[dname+"_"]);
+ delete polygons[dname+"_"];
+ }
if (typeof markers[dname] != "undefined") {
- ws.send(JSON.stringify({action:"delete", name:dname}));
layers[markers[dname].lay].removeLayer(markers[dname]);
+ map.removeLayer(markers[dname]);
delete markers[dname];
}
+ ws.send(JSON.stringify({action:"delete", name:dname}));
map.closePopup();
}
// the MAIN add something to map function
function setMarker(data) {
- //console.log(typeof data, data);
+ //console.log("DATA",typeof data, data);
var ll;
var lli = null;
var stay = popped;
@@ -763,20 +763,23 @@ function setMarker(data) {
}
var lay = data.layer || "unknown";
if (typeof layers[lay] == "undefined") { // add layer if if doesn't exist
- //layers[lay] = new L.LayerGroup().addTo(map);
+ //layers[lay] = new L.LayerGroup();
layers[lay] = new L.MarkerClusterGroup({
maxClusterRadius:50,
spiderfyDistanceMultiplier:1.8,
- disableClusteringAtZoom:clusterAt,
+ disableClusteringAtZoom:clusterAt
//zoomToBoundsOnClick:false
- }).addTo(map);
+ });
overlays[lay] = layers[lay];
- //if (!inIframe) {
- layercontrol.addOverlay(layers[lay],lay);
- //}
+ layercontrol.addOverlay(layers[lay],lay);
+ map.addLayer(overlays[lay]);
+ console.log("ADDED LAYER",lay,layers);
}
- if (typeof markers[data.name] != "undefined") { layers[lay].removeLayer(markers[data.name]); }
+ if (typeof markers[data.name] != "undefined") {
+ 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.deleted) { // remove markers we are told to
@@ -1191,21 +1194,19 @@ function doCommand(cmd) {
if (!existsalready) {
layercontrol.addOverlay(overlays[cmd.map.overlay],cmd.map.overlay);
}
- overlays[cmd.map.overlay].addTo(map);
+ map.addLayer(overlays[cmd.map.overlay]);
}
// Add a new velocity overlay layer
if (cmd.map && cmd.map.hasOwnProperty("overlay") && cmd.map.hasOwnProperty("velocity") ) {
- console.log("M",cmd.map);
if (overlays.hasOwnProperty(cmd.map.overlay)) {
map.removeLayer(overlays[cmd.map.overlay]);
existsalready = true;
}
- console.log("E",existsalready);
overlays[cmd.map.overlay] = L.velocityLayer(cmd.map.velocity);
if (!existsalready) {
layercontrol.addOverlay(overlays[cmd.map.overlay],cmd.map.overlay);
}
- overlays[cmd.map.overlay].addTo(map);
+ map.addLayer(overlays[cmd.map.overlay]);
}
// Add a new overlay layer
if (cmd.map && cmd.map.hasOwnProperty("overlay") && cmd.map.hasOwnProperty("url") && cmd.map.hasOwnProperty("opt")) {
@@ -1231,7 +1232,7 @@ function doCommand(cmd) {
if (!existsalready) {
layercontrol.addOverlay(overlays[cmd.map.overlay],cmd.map.overlay);
}
- overlays[cmd.map.overlay].addTo(map);
+ map.addLayer(overlays[cmd.map.overlay]);
}
// Swap a base layer
if (cmd.layer && basemaps.hasOwnProperty(cmd.layer)) {
@@ -1241,7 +1242,7 @@ function doCommand(cmd) {
}
// Add an overlay
if (cmd.layer && overlays.hasOwnProperty(cmd.layer)) {
- overlays[cmd.layer].addTo(map);
+ map.addLayer(overlays[cmd.map.overlay]);
}
var clat = map.getCenter().lat;
var clon = map.getCenter().lng;
diff --git a/worldmap/worldmap.appcache b/worldmap/worldmap.appcache
index 62c2072..0a1b8a0 100644
--- a/worldmap/worldmap.appcache
+++ b/worldmap/worldmap.appcache
@@ -1,5 +1,5 @@
CACHE MANIFEST
-# date: May 30th 2018 - v1.1.16
+# date: June 6th 2018 - v1.2.0
CACHE:
index.html