Add geocoding names to search
This commit is contained in:
parent
f8c9a71230
commit
d77c6e70ec
@ -1,5 +1,6 @@
|
||||
### Change Log for Node-RED Worldmap
|
||||
|
||||
- v1.5.11 - Let search also try geocoding lookup if not marks found.
|
||||
- v1.5.10 - Allow latest mark added to open popup, and allow `popped=false` to close.
|
||||
- v1.5.7 - Tidy up sidc entry, and drag-ability of nodes on drawing layer.
|
||||
- v1.5.6 - Add search command and clear search functionality.
|
||||
|
@ -9,6 +9,7 @@ map web page for plotting "things" on.
|
||||
|
||||
### Updates
|
||||
|
||||
- v1.5.11 - Let search also try geocoding lookup if not marks found.
|
||||
- v1.5.10 - Allow latest mark added to open popup, and allow `popped=false` to close.
|
||||
- v1.5.7 - Tidy up sidc entry, and drag-ability of nodes on drawing layer.
|
||||
- v1.5.6 - Add search command and clear search functionality.
|
||||
@ -242,7 +243,7 @@ Optional properties include
|
||||
- **lon** - move map to specified longitude.
|
||||
- **zoom** - move map to specified zoom level (1 - world, 13 to 20 max zoom depending on map).
|
||||
- **layer** - set map to specified base layer name - `{command:{layer:"Esri"}}`
|
||||
- **search** - search markers on map for name containing `string`. An empty string `""` clears the search results. - `{command:{search:"Dave"}}`
|
||||
- **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:"Dave"}}`
|
||||
- **showlayer** - show the named overlay(s) - `{command:{showlayer:"foo"}}` or `{command:{showlayer:["foo","bar"]}}`
|
||||
- **hidelayer** - hide the named overlay(s) - `{command:{hidelayer:"bar"}}` or `{command:{hidelayer:["bar","another"}}`
|
||||
- **side** - add a second map alongside with slide between them. Use the name of a *baselayer* to add - or "none" to remove the control. - `{command:{side:"Esri Satellite"}}`
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "node-red-contrib-web-worldmap",
|
||||
"version": "1.5.10",
|
||||
"version": "1.5.11",
|
||||
"description": "A Node-RED node to provide a web page of a world map for plotting things on.",
|
||||
"dependencies": {
|
||||
"cgi": "0.3.1",
|
||||
|
@ -391,11 +391,37 @@ function doSearch() {
|
||||
}
|
||||
}
|
||||
moveToMarks();
|
||||
if (marks.length === 0) {
|
||||
// If no markers found let's try a geolookup...
|
||||
var protocol = location.protocol;
|
||||
if (protocol == "file:") { protocol = "https:"; }
|
||||
var searchUrl = protocol + "//nominatim.openstreetmap.org/search?format=json&limit=1&q=";
|
||||
|
||||
fetch(searchUrl + value) // Call the fetch function passing the url of the API as a parameter
|
||||
.then((resp) => resp.json())
|
||||
.then(function(data) {
|
||||
if (data.length > 0) {
|
||||
var bb = data[0].boundingbox;
|
||||
map.fitBounds([ [bb[0],bb[2]], [bb[1],bb[3]] ]);
|
||||
map.panTo([data[0].lat, data[0].lon]);
|
||||
}
|
||||
else {
|
||||
document.getElementById('searchRes').innerHTML = " <font color='#ff0'>Not Found</font>";
|
||||
}
|
||||
})
|
||||
.catch(function(err) {
|
||||
if (err.toString() === "TypeError: Failed to fetch") {
|
||||
document.getElementById('searchRes').innerHTML = " <font color='#ff0'>Not Found</font>";
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (lockit) {
|
||||
document.getElementById('searchRes').innerHTML = " <font color='#ff0'>Found "+marks.length+" results within bounds.</font>";
|
||||
} else {
|
||||
document.getElementById('searchRes').innerHTML = " <font color='#ff0'>Found "+marks.length+" results.</font>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Jump to a markers position - centralise it on map
|
||||
|
@ -1,5 +1,5 @@
|
||||
CACHE MANIFEST
|
||||
# date: Nov 9th 2018 - v1.5.10
|
||||
# date: Nov 9th 2018 - v1.5.11
|
||||
|
||||
CACHE:
|
||||
index.html
|
||||
|
Loading…
Reference in New Issue
Block a user