diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c2b616..921b610 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ### Change Log for Node-RED Worldmap + - v1.1.13 - Add ability to set a building using a GeoJSON Feature set. {name:"MyTower":building:{...feature sets...}} - v1.1.12 - README changes, split out CHANGELOG.md - v1.1.11 - fix websocket multiple connections - v1.1.9 - add ability to add geoJSON layers diff --git a/README.md b/README.md index 070b956..4f23f18 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,43 @@ There are also several special icons... - **unknown** : pseudo NATO style yellow square. - **earthquake** : black circle - diameter proportional to `msg.mag`. +### Buildings + +The OSM Buildings layer is available in the layers menu. You can replace this with a building of your own by +sending a msg.payload containing a name and a building property. The building property should be +a GeoJSON Feature Collection as per the OSMBuildings spec. + + { name:"My Block", building: { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + "wallColor": "rgb(0,0,255)", + "roofColor": "rgb(128,128,255)", + "height": 50, + "minHeight": 0, + "piso": 0 + }, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-1.398163, 51.026591], + [-1.397781, 51.026597], + [-1.397751, 51.025430], + [-1.398148, 51.025427], + [-1.398163, 51.026591] + ] + ] + } + } + ] } + } + +**Note**: the object you supply will replace the whole buildings layer. To delete the building send a msg with a name and the building property set to "" (blank string). + + ### Areas and Lines If the payload contains an **area** property - that is an array of co-ordinates, e.g. diff --git a/package.json b/package.json index 6cf3236..aa0b8a7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-web-worldmap", - "version": "1.1.12", + "version": "1.1.13", "description": "A Node-RED node to provide a web page of a world map for plotting things on.", "dependencies": { "express": "^4.16.3", diff --git a/worldmap/index.html b/worldmap/index.html index 2a21a0b..2e31458 100644 --- a/worldmap/index.html +++ b/worldmap/index.html @@ -743,6 +743,19 @@ function setMarker(data) { opt.clickable = (data.hasOwnProperty("clickable")) ? data.clickable : false; opt.fill = (data.hasOwnProperty("fill")) ? data.fill : true; + // Replace building + if (data.hasOwnProperty("building")) { + if ((data.building === "") && layers.hasOwnProperty("buildings")) { + map.removeLayer(layers["buildings"]); + layercontrol._update(); + layers["buildings"] = overlays["buildings"].set(""); + return; + } + //layers["buildings"] = new OSMBuildings(map).set(data.building); + layers["buildings"] = overlays["buildings"].set(data.building); + map.addLayer(layers["buildings"]); + return; + } var lay = data.layer || "unknown"; if (typeof layers[lay] == "undefined") { // add layer if if doesn't exist //layers[lay] = new L.LayerGroup().addTo(map); diff --git a/worldmap/worldmap.appcache b/worldmap/worldmap.appcache index 6659bdd..7201252 100644 --- a/worldmap/worldmap.appcache +++ b/worldmap/worldmap.appcache @@ -1,5 +1,5 @@ CACHE MANIFEST -# date: Jan 31st 2018 - v1.1.10 +# date: May 28th 2018 - v1.1.13 CACHE: index.html