Add new building support

This commit is contained in:
Dave Conway-Jones 2018-05-29 09:04:32 +01:00
parent 4d5170373f
commit 6f921380bd
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
5 changed files with 53 additions and 2 deletions

View File

@ -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

View File

@ -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.

View File

@ -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",

View File

@ -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);

View File

@ -1,5 +1,5 @@
CACHE MANIFEST
# date: Jan 31st 2018 - v1.1.10
# date: May 28th 2018 - v1.1.13
CACHE:
index.html