Slight reformatting / linting of search PR

This commit is contained in:
Dave Conway-Jones 2018-10-25 09:56:42 +01:00
parent 27dd9a1fea
commit 84ed5e3a2e
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
4 changed files with 31 additions and 32 deletions

View File

@ -8,6 +8,7 @@ map web page for plotting "things" on.
![Map Image](https://dceejay.github.io/pages/images/redmap.png)
### Updates
- v1.5.6 - Add search command and clear search functionality.
- v1.5.5 - Allow multiple overlays to be enabled at once - Issue #53
- v1.5.4 - Allow remote update of the split position via `msg.command.split`
@ -246,7 +247,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** - add dynamic search control. Object contains the string to be searched and if it contains **clear** then it clears the search results.
- **search** - search markers on map for name containing `string`. 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"}}`

View File

@ -1,6 +1,6 @@
{
"name": "node-red-contrib-web-worldmap",
"version": "1.5.5",
"version": "1.5.6",
"description": "A Node-RED node to provide a web page of a world map for plotting things on.",
"dependencies": {
"cgi": "0.3.1",

View File

@ -409,22 +409,22 @@ function moveToMarks() {
}
// Clear Search With Marker names
function clearSearch()
{
var value = document.getElementById('search').value;
marks = [];
marksIndex = 0;
for (var key in markers) {
if ( (~(key.toLowerCase()).indexOf(value.toLowerCase())) && (mb.contains(markers[key].getLatLng()))) {
marks.push(markers[key]);
}
}
removeMarks();
if (lockit) {
document.getElementById('searchRes').innerHTML = "";
} else {
document.getElementById('searchRes').innerHTML = "";
}
function clearSearch() {
var value = document.getElementById('search').value;
marks = [];
marksIndex = 0;
for (var key in markers) {
if ( (~(key.toLowerCase()).indexOf(value.toLowerCase())) && (mb.contains(markers[key].getLatLng()))) {
marks.push(markers[key]);
}
}
removeMarks();
if (lockit) {
document.getElementById('searchRes').innerHTML = "";
}
else {
document.getElementById('searchRes').innerHTML = "";
}
}
function removeMarks() {
@ -500,7 +500,7 @@ map.on('overlayadd', function(e) {
overlays["drawing"].bringToFront();
// And the actual draw controls
map.addControl(drawControl);
// Add the color change button
// Add the color change buttons
//colorControl.addTo(map);
}
ws.send(JSON.stringify({action:"addlayer", name:e.name}));
@ -515,7 +515,7 @@ map.on('overlayremove', function(e) {
layers["_daynight"].clearLayers();
}
if (e.name == "drawing") {
map.removeControl(colorControl);
//map.removeControl(colorControl);
map.removeControl(drawControl);
}
//else console.log("layer del :",e.name);
@ -1539,18 +1539,16 @@ function doCommand(cmd) {
basemaps[baselayername].addTo(map);
}
// Add search command
if (cmd.search) {
if(cmd.search !== "clear")
{
console.log("SEARCH",cmd.search);
if (cmd.hasOwnProperty("search") && (typeof cmd.search === "string")) {
document.getElementById('search').value = cmd.search;
openMenu();
doSearch();
}else {
document.getElementById('search').value = "";
closeMenu();
clearSearch();
}
if (cmd.search !== "") {
openMenu();
doSearch();
}
else {
closeMenu();
clearSearch();
}
}
// Add side by side control
if (cmd.side && (cmd.side === "none")) {

View File

@ -1,5 +1,5 @@
CACHE MANIFEST
# date: Oct 17th 2018 - v1.5.5
# date: Oct 17th 2018 - v1.5.6
CACHE:
index.html