summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Koch <markus@notsyncing.net>2020-04-19 23:09:26 +0200
committerMarkus Koch <markus@notsyncing.net>2020-04-19 23:09:26 +0200
commitbfaacd813be434e4146e824c793aa4f73711a84a (patch)
tree9f7fdb327c934cfa8b598f508ab61d59c7a51c8b
parent9c703b50aa4f382a882a5d142bb11d313188833f (diff)
downloadlifomapserver-bfaacd813be434e4146e824c793aa4f73711a84a.tar.gz
lifomapserver-bfaacd813be434e4146e824c793aa4f73711a84a.tar.bz2
lifomapserver-bfaacd813be434e4146e824c793aa4f73711a84a.zip
Add street names to search
-rw-r--r--htdocs/mapscript.js17
-rw-r--r--htdocs/streeteditor.js3
2 files changed, 18 insertions, 2 deletions
diff --git a/htdocs/mapscript.js b/htdocs/mapscript.js
index abba88c..65f7ade 100644
--- a/htdocs/mapscript.js
+++ b/htdocs/mapscript.js
@@ -232,6 +232,14 @@ function toggle_search() {
function htmlEntities(str) {
return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}
+
+function polyline_get_middle_coords(coords) {
+ var ret = [2];
+ ret[0] = coords[0][0] + (coords[coords.length - 1][0] - coords[0][0]) / 2;
+ ret[1] = coords[0][1] + (coords[coords.length - 1][1] - coords[0][1]) / 2;
+ return ret;
+}
+
var regex;
function search(e) {
var query = htmlEntities(document.getElementById("search_query").value);
@@ -253,6 +261,15 @@ function search(e) {
results.appendChild(el);
}
break;
+ case "LineString":
+ regex = new RegExp(query, 'i');
+ if (item.feature.properties.name.match(regex)) {
+ 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>";
+ results.appendChild(el);
+ }
+ break;
default:
break;
}
diff --git a/htdocs/streeteditor.js b/htdocs/streeteditor.js
index 53f9b52..340a10a 100644
--- a/htdocs/streeteditor.js
+++ b/htdocs/streeteditor.js
@@ -78,8 +78,7 @@ if (editor_mode) {
polyline.enableEdit();
if (interactive) {
console.log(coords);
- latlng = L.latLng(coords[0][0] + (coords[coords.length - 1][0] - coords[0][0]) / 2,
- coords[0][1] + (coords[coords.length - 1][1] - coords[0][1]) / 2);
+ latlng = L.latLng(polyline_get_middle_coords(coords));
console.log("NEW=" + latlng);
jump_to(latlng, 8);
}