diff options
author | Markus Koch <markus@notsyncing.net> | 2020-04-19 23:28:54 +0200 |
---|---|---|
committer | Markus Koch <markus@notsyncing.net> | 2020-04-19 23:28:54 +0200 |
commit | 9bac7e4678ef1d05e1d9fb4b24e79b05b70bae84 (patch) | |
tree | 1d0f3879a11a449e281efd676c866ea3c302a1be | |
parent | bfaacd813be434e4146e824c793aa4f73711a84a (diff) | |
download | lifomapserver-9bac7e4678ef1d05e1d9fb4b24e79b05b70bae84.tar.gz lifomapserver-9bac7e4678ef1d05e1d9fb4b24e79b05b70bae84.tar.bz2 lifomapserver-9bac7e4678ef1d05e1d9fb4b24e79b05b70bae84.zip |
Highlight search result streets in red
-rw-r--r-- | htdocs/mapscript.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/htdocs/mapscript.js b/htdocs/mapscript.js index 65f7ade..5ae09a2 100644 --- a/htdocs/mapscript.js +++ b/htdocs/mapscript.js @@ -241,6 +241,8 @@ function polyline_get_middle_coords(coords) { } var regex; +var highlighted_line; +var default_street_color = "#3388ff"; function search(e) { var query = htmlEntities(document.getElementById("search_query").value); document.getElementById('search_results').innerHTML = ""; @@ -262,8 +264,16 @@ function search(e) { } break; case "LineString": + if (item.options.color != default_street_color) { // De-hilight last search + item.options.color = default_street_color; + item.redraw(); + } regex = new RegExp(query, 'i'); + if (item.feature.properties.name.match(regex)) { + console.log(item.options.color); + item.options.color = "#FF0000"; + item.redraw(); el = document.createElement("li"); zpos = polyline_get_middle_coords(item.feature.geometry.coordinates); el.innerHTML = "[" + layers._layers[i].name + "] " + '<a href="#" onclick="latLng2 = L.latLng(' + zpos[1] + ',' + zpos[0] + '); jump_to(latLng2); return false;">' + item.feature.properties.name + "</a>"; |