Add bounds command capability

This commit is contained in:
Dave Conway-Jones 2022-01-16 15:35:27 +00:00
parent 49198b79d2
commit 7d0badd134
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
3 changed files with 8 additions and 0 deletions

View File

@ -1,5 +1,6 @@
### Change Log for Node-RED Worldmap ### Change Log for Node-RED Worldmap
- v2.25.0 - Add bounds command to set overall map bounds.
- v2.24.3 - Fix geojson incorrect fill. - v2.24.3 - Fix geojson incorrect fill.
- v2.24.2 - Changes to drawing colours to be more visible. - v2.24.2 - Changes to drawing colours to be more visible.
- v2.24.1 - Fix ellipse accuracy. - v2.24.1 - Fix ellipse accuracy.

View File

@ -11,6 +11,7 @@ map web page for plotting "things" on.
### Updates ### Updates
- v2.25.0 - Add bounds command to set overall map bounds.
- v2.24.3 - Fix geojson incorrect fill. - v2.24.3 - Fix geojson incorrect fill.
- v2.24.2 - Changes to drawing colours to be more visible. - v2.24.2 - Changes to drawing colours to be more visible.
- v2.24.1 - Fix ellipse accuracy - v2.24.1 - Fix ellipse accuracy
@ -388,6 +389,7 @@ Optional properties include
- **lat** - move map to specified latitude. - **lat** - move map to specified latitude.
- **lon** - move map to specified longitude. - **lon** - move map to specified longitude.
- **zoom** - move map to specified zoom level (1 - world, 13 to 20 max zoom depending on map). - **zoom** - move map to specified zoom level (1 - world, 13 to 20 max zoom depending on map).
- **bounds** - if set to an array `[ [ lat(S), lon(W) ], [lat(N), lon(E)] ]` - sets the overall map bounds.
- **layer** - set map to specified base layer name - `{"command":{"layer":"Esri"}}` - **layer** - set map to specified base layer name - `{"command":{"layer":"Esri"}}`
- **search** - search markers on map for name containing `string`. If not found in existing markers, will then try geocoding looking using Nominatim. An empty string `""` clears the search results. - `{"command":{"search":"Winchester"}}` - **search** - search markers on map for name containing `string`. If not found in existing markers, will then try geocoding looking using Nominatim. An empty string `""` clears the search results. - `{"command":{"search":"Winchester"}}`
- **showlayer** - show the named overlay(s) - `{"command":{"showlayer":"foo"}}` or `{"command":{"showlayer":["foo","bar"]}}` - **showlayer** - show the named overlay(s) - `{"command":{"showlayer":"foo"}}` or `{"command":{"showlayer":["foo","bar"]}}`

View File

@ -2622,6 +2622,11 @@ function doCommand(cmd) {
map.touchZoom.enable(); map.touchZoom.enable();
} }
} }
if (cmd.hasOwnProperty("bounds")) { // Move/Zoom map to new bounds
if (cmd.bounds.length === 2 && cmd.bounds[0].length === 2 && cmd.bounds[1].length === 2) {
map.fitBounds(cmd.bounds);
}
}
} }
// handle any incoming GEOJSON directly - may style badly // handle any incoming GEOJSON directly - may style badly