summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Koch <markus@notsyncing.net>2020-06-14 12:02:32 +0200
committerMarkus Koch <markus@notsyncing.net>2020-06-14 12:02:32 +0200
commitfcc26a7fa573569a20fbbabaf768ae53ff29bfa6 (patch)
tree1e43c7d1c98d7ed408d97e9b0cce11ae7a51edcd
parent134d70dc9fbdbed4f4cd3827295fbbd64a2ee5f2 (diff)
downloadlifomapserver-fcc26a7fa573569a20fbbabaf768ae53ff29bfa6.tar.gz
lifomapserver-fcc26a7fa573569a20fbbabaf768ae53ff29bfa6.tar.bz2
lifomapserver-fcc26a7fa573569a20fbbabaf768ae53ff29bfa6.zip
Add mouse coordinate display to bottom left
-rw-r--r--htdocs/mapscript.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/htdocs/mapscript.js b/htdocs/mapscript.js
index 3eccb65..a27ee10 100644
--- a/htdocs/mapscript.js
+++ b/htdocs/mapscript.js
@@ -606,6 +606,31 @@ L.GotoControl = L.MyControl.extend({
mymap.addControl(new L.SearchControl());
mymap.addControl(new L.GotoControl());
+L.CurrentPosControl = L.Control.extend({
+ options: {
+ position : 'bottomleft',
+ callback: null,
+ kind: "",
+ html: ''
+ },
+ onAdd: function (map) {
+ container = L.DomUtil.create('div', 'leaflet-control-scale leaflet-bar');
+ container.style.visibility = "hidden";
+ div = L.DomUtil.create('div', '', container);
+ div.style.backgroundColor = "white";
+ div.style.paddingLeft = "4px";
+ div.style.paddingRight = "4px";
+ div.style.borderRadius = "2px";
+ div.style.margin = "2px";
+ div.style.opacity = "0.6";
+ div.style.fontWeight = "bold";
+ div.innerHTML = "";
+ div.id = "current_position_label";
+ return container;
+ }
+});
+mymap.addControl(new L.CurrentPosControl());
+
var popup = L.popup();
L.AwesomeMarkers.Icon.prototype.options.prefix = 'fa';
@@ -687,6 +712,17 @@ function update_outline_visibility() {
});
}
+function update_current_mouse_position(e) {
+ var lbl = document.getElementById('current_position_label');
+ if (e.type == "mouseout") {
+ lbl.parentElement.style.visibility = "hidden";
+ return;
+ }
+ lbl.parentElement.style.visibility = "visible";
+ pos = resolve_latlng(e.latlng);
+ lbl.innerHTML = pos.lng + "," + pos.lat;
+}
+
mymap.on('zoomend', function () {is_user_drag = 1; update_hash_from_position();});
mymap.on('zoomend', update_aa_status);
mymap.on('zoomend', update_street_width);
@@ -695,6 +731,8 @@ mymap.on('moveend', update_hash_from_position);
mymap.on('dragstart', function () { is_user_drag = 1;});
mymap.on('keydown', function (e) { if (e.originalEvent.code.match(/Arrow.*/)) is_user_drag = 1;});
mymap.on('overlayadd', function (e) { update_street_width(); update_outline_visibility(); });
+mymap.on('mousemove', update_current_mouse_position);
+mymap.on('mouseout', update_current_mouse_position);
function onHashChange(e, hash=null) {
if (!hash)