Merge pull request #1756 from umap-project/edit-in-osm-in-contextmenu
feat: add link in contextmenu to edit map in OSM
This commit is contained in:
commit
67bc181098
2 changed files with 16 additions and 0 deletions
|
@ -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")
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue