Highlight search result streets in red

This commit is contained in:
Markus Koch 2020-04-19 23:28:54 +02:00
parent bfaacd813b
commit 9bac7e4678

View File

@ -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>";