From 9bac7e4678ef1d05e1d9fb4b24e79b05b70bae84 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Sun, 19 Apr 2020 23:28:54 +0200 Subject: [PATCH] Highlight search result streets in red --- htdocs/mapscript.js | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 + "] " + '' + item.feature.properties.name + "";