Highlight search result streets in red
This commit is contained in:
parent
bfaacd813b
commit
9bac7e4678
@ -241,6 +241,8 @@ function polyline_get_middle_coords(coords) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var regex;
|
var regex;
|
||||||
|
var highlighted_line;
|
||||||
|
var default_street_color = "#3388ff";
|
||||||
function search(e) {
|
function search(e) {
|
||||||
var query = htmlEntities(document.getElementById("search_query").value);
|
var query = htmlEntities(document.getElementById("search_query").value);
|
||||||
document.getElementById('search_results').innerHTML = "";
|
document.getElementById('search_results').innerHTML = "";
|
||||||
@ -262,8 +264,16 @@ function search(e) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "LineString":
|
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');
|
regex = new RegExp(query, 'i');
|
||||||
|
|
||||||
if (item.feature.properties.name.match(regex)) {
|
if (item.feature.properties.name.match(regex)) {
|
||||||
|
console.log(item.options.color);
|
||||||
|
item.options.color = "#FF0000";
|
||||||
|
item.redraw();
|
||||||
el = document.createElement("li");
|
el = document.createElement("li");
|
||||||
zpos = polyline_get_middle_coords(item.feature.geometry.coordinates);
|
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>";
|
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>";
|
||||||
|
Loading…
Reference in New Issue
Block a user