From 209fcbd441a8692ed911c195fd7c05eaa53ed514 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Wed, 7 Aug 2019 21:56:26 +0100 Subject: [PATCH] Fix track polygons layer, clickable, and ensure fit is boolean To close #109, to address #110, bump package --- README.md | 5 +++-- package.json | 2 +- worldmap/worldmap.js | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2f6c6ac..b28a12e 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ map web page for plotting "things" on. ### Updates +- v2.0.19 - ensure `fit` option is boolean, Issue #109. Fix tracks, Issue #110. - v2.0.18 - Stop map contextmenu bleedthrough to marker. Add compress middleware. - v2.0.17 - Let clear command also clear tracks from tracks node - v2.0.16 - Revert use of ES6 import. Keep IE11 happy for while @@ -411,7 +412,7 @@ The geojson features may contain a `properties` property. That may also include The `opt` property is optional. See the Leaflet geojson docs for more info on possible options. Note: only simple options are supported as functions cannot be serialised. -The `fit` property is optional. If present the map will automatically zoom to fit the area relevant to the geojson. +The `fit` property is optional. If boolean true the map will automatically zoom to fit the area relevant to the geojson. see http://leafletjs.com/examples/geojson/ for more details about options for opt. @@ -430,7 +431,7 @@ As per the geojson overlay you can also inject a KML layer, GPX layer or TOPOJSO - **icon** : font awesome icon name. - **iconColor** : Standard CSS colour name or #rrggbb hex value. -Again the `fit` property can be added to make the map zoom to the relevant area. +Again the boolean `fit` property can be added to make the map zoom to the relevant area. #### To add a Velocity Grid Overlay diff --git a/package.json b/package.json index a52eccf..84e45ed 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-web-worldmap", - "version": "2.0.18", + "version": "2.0.19", "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/worldmap.js b/worldmap/worldmap.js index 83f75d7..77f5e8f 100644 --- a/worldmap/worldmap.js +++ b/worldmap/worldmap.js @@ -1011,7 +1011,7 @@ function setMarker(data) { delete data.action; if (typeof markers[data.name] != "undefined") { - if (markers[data.name].lay !== data.layer) { + if (markers[data.name].lay !== lay) { delMarker(data.name); } else { @@ -1055,12 +1055,12 @@ function setMarker(data) { if (polygons[data.name] !== undefined) { polygons[data.name].lay = lay; - if (opt.clickable) { + if (opt.clickable === true) { var words = ""+data.name+""; if (data.popup) { var words = words + "
" + data.popup; } polygons[data.name].bindPopup(words, {autoClose:false, closeButton:true, closeOnClick:false, minWidth:200}); } - polygons[data.name] = rightmenu(polygons[data.name]); + //polygons[data.name] = rightmenu(polygons[data.name]); // DCJ Investigate layers[lay].addLayer(polygons[data.name]); } else { @@ -1678,7 +1678,7 @@ function doCommand(cmd) { layercontrol.addOverlay(overlays[cmd.map.overlay],cmd.map.overlay); } map.addLayer(overlays[cmd.map.overlay]); - if (cmd.map.hasOwnProperty("fit")) { map.fitBounds(overlays[cmd.map.overlay].getBounds()); } + if (cmd.map.hasOwnProperty("fit") && cmd.map.fit === true)) { map.fitBounds(overlays[cmd.map.overlay].getBounds()); } } // Add a new NVG XML overlay layer if (cmd.map && cmd.map.hasOwnProperty("overlay") && cmd.map.hasOwnProperty("nvg") ) {