Compare commits

...

3 Commits

Author SHA1 Message Date
4c7590a212 Only display search results 2020-04-19 20:21:13 +02:00
e1baa251fb Fix Firefox compatibility once more 2020-04-19 20:12:57 +02:00
d1e0c3fffa Fix x/y swap in jump_to function 2020-04-19 20:12:39 +02:00

View File

@ -184,7 +184,7 @@ function jump_to(latlng, zoom = -1) {
if (zoom == -1)
zoom = mymap.getZoom();
if (!editor_mode)
document.location.hash = "#" + Math.round(latlng.lat) + "," + Math.round(latlng.lng) + "," + zoom;
document.location.hash = "#" + Math.round(latlng.lng) + "," + Math.round(latlng.lat) + "," + zoom;
else
mymap.setView(latlng, zoom);
}
@ -235,6 +235,7 @@ function htmlEntities(str) {
var regex;
function search(e) {
var query = htmlEntities(document.getElementById("search_query").value);
document.getElementById('search_results').innerHTML = "";
if (query.length > 0 || e.key == "Enter") {
results = document.createElement("ul");
for (var i = 0; i < layers._layers.length; i++) {
@ -248,7 +249,7 @@ function search(e) {
regex = new RegExp(query, 'i');
if (item.feature.properties.name.match(regex)) {
el = document.createElement("li");
el.innerHTML = "[" + layers._layers[i].name + "] " + '<a href="javascript:layers._layers[' + i + '].layer._layers[' + item._leaflet_id + '].fire(\'click\') ">' + item.feature.properties.name + "</a>";
el.innerHTML = "[" + layers._layers[i].name + "] " + '<a href="#" onclick="layers._layers[' + i + '].layer._layers[' + item._leaflet_id + '].fire(\'click\'); return false;">' + item.feature.properties.name + "</a>";
results.appendChild(el);
}
break;
@ -257,10 +258,9 @@ function search(e) {
}
}
}
document.getElementById('search_results').innerHTML = "Search results for " + query;
document.getElementById('search_results').appendChild(results);
return false;
}
return false;
}
L.MyControl = L.Control.extend({