aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/MenuItem.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'src/MenuItem.mjs')
-rw-r--r--src/MenuItem.mjs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/MenuItem.mjs b/src/MenuItem.mjs
index 103f43e..13dbc44 100644
--- a/src/MenuItem.mjs
+++ b/src/MenuItem.mjs
@@ -586,3 +586,26 @@ export const editMap = (map, dumbymap) => {
586 ], 586 ],
587 }) 587 })
588} 588}
589
590export const addLinkbyNominatim = (range) => {
591 return Item({
592 text: 'Add Link by Geocoding',
593 onclick: () => {
594 const place = range.toString()
595 fetch(`https://nominatim.openstreetmap.org/search?q=${place.toString()}&format=json`)
596 .then(res => res.json())
597 .then(places => {
598 if (places.length === 0) return
599 console.log('nomiatim', places)
600 range.deleteContents()
601 places.forEach(p => {
602 const a = document.createElement('a')
603 a.className = 'not-geolink from-geocoding'
604 a.href = `geo:${p.lat},${p.lon}?name=${p.name}&osm=${p.osm_type}/${p.osm_id}`
605 a.textContent = place
606 range.insertNode(a)
607 })
608 })
609 },
610 })
611}