feat: add link in contextmenu to edit map in OSM

fix #1651
This commit is contained in:
Yohan Boniface 2024-04-17 09:34:39 +02:00
parent 05fd33deb7
commit 87e2467a4c
2 changed files with 16 additions and 0 deletions

View file

@ -239,6 +239,7 @@ UMAP_EXTRA_URLS = {
"routing": "http://www.openstreetmap.org/directions?engine=osrm_car&route={lat},{lng}&locale={locale}#map={zoom}/{lat}/{lng}", # noqa
"ajax_proxy": "/ajax-proxy/?url={url}&ttl={ttl}",
"search": "https://photon.komoot.io/api/?",
"edit_in_osm": "https://www.openstreetmap.org/edit#map={zoom}/{lat}/{lng}",
}
UMAP_KEEP_VERSIONS = env.int("UMAP_KEEP_VERSIONS", default=10)
SITE_URL = env("SITE_URL", default="http://umap.org")

View file

@ -1769,9 +1769,24 @@ U.Map = L.Map.extend({
callback: this.openExternalRouting,
})
}
if (this.options.urls.edit_in_osm) {
items.push('-', {
text: L._('Edit in OpenStreetMap'),
callback: this.editInOSM,
})
}
this.options.contextmenuItems = items
},
editInOSM: function (e) {
const url = this.urls.get('edit_in_osm', {
lat: e.latlng.lat,
lng: e.latlng.lng,
zoom: Math.max(this.getZoom(), 16),
})
if (url) window.open(url)
},
openExternalRouting: function (e) {
const url = this.urls.get('routing', {
lat: e.latlng.lat,