Location Picker

Both
Rightclick and Button
with higher precision
This commit is contained in:
Moorviper 2016-02-25 15:47:07 +01:00
commit 115d9abab9
5 changed files with 131 additions and 3 deletions

View file

@ -20,7 +20,9 @@ define(["map/clientlayer", "map/labelslayer",
var button = L.DomUtil.create("button", "add-layer")
button.textContent = ""
L.DomEvent.disableClickPropagation(button)
// L.DomEvent.disableClickPropagation(button)
// Click propagation isn't disabled as this causes problems with the
// location picking mode; instead propagation is stopped in onClick().
L.DomEvent.addListener(button, "click", this.f, this)
this.button = button
@ -233,7 +235,7 @@ define(["map/clientlayer", "map/labelslayer",
}
function showCoordinates(e) {
window.prompt("Koordinaten (Lat, Lng)", e.latlng.lat.toFixed(6) + ", " + e.latlng.lng.toFixed(6))
window.prompt("Koordinaten (Lat, Lng)", e.latlng.lat.toFixed(9) + ", " + e.latlng.lng.toFixed(9))
disableCoords()
}
@ -271,6 +273,11 @@ define(["map/clientlayer", "map/labelslayer",
}
}
function contextMenuGotoLocation(e) {
console.log("context menu called at ", e)
router.gotoLocation(e.latlng)
}
var el = document.createElement("div")
el.classList.add("map")
@ -292,6 +299,7 @@ define(["map/clientlayer", "map/labelslayer",
map.on("locationfound", locationFound)
map.on("locationerror", locationError)
map.on("dragend", saveView)
map.on("contextmenu", contextMenuGotoLocation)
addButton(locateUserButton)
addButton(showCoordsPickerButton)
@ -498,6 +506,10 @@ define(["map/clientlayer", "map/labelslayer",
updateView()
}
self.gotoLocation = function () {
//ignore
}
self.destroy = function () {
clearButtons()
map.remove()