6
Generate link that will auto-open app/browser map based just on latitude and longitude - programming.dev
programming.devHello guys, I’m relatively new to OSM but have found it quite useful and
feature-rich since I made the switch to a degoogled phone OS. I now have a
question about generating OSM compatible links much like google maps has where I
can send a friend a sharable link and when they click it it automatically opens
their app (or browser if the app cant be found) to the OSM map with the location
under a pin so that they can do whatever with it (most usefully is to “Navigate”
to it and get directions) I’m so new to it though that I don’t even know if the
concept of a “link” which opens the map exists in the context of OSM. If it does
though, I would love to know where I can read up on these links’ formats so that
I can see how I might generate them from lat+long coords through software. Many
thanks in advance! Edit: In OsmAnd when I want to share a location, I can select
Share then Copy. That will put some text along with a link of the following
format in my clipboard:
https://osmand.net/map?pin=35.96296%2C-5.50856#10/35.96296/-5.50856
[https://osmand.net/map?pin=35.96296%2C-5.50856#10/35.96296/-5.50856] I get the
parts up until the #10. What does the #10 mean and why do the coordinates appear
2 times in the link, once before #10 an once after?


The most obvious solution is this:
https://openstreetmap.org/?mlat<lat>&mlon=<lon>(replace<lat>and<lon>accordingly). Apps like OrganicMaps/CoMaps and OsmAnd will install a handler for this (at least on Android, not sure about iOS) that will allow you to open such links with the app easily (it usually shows an “open with” menu when you click on such link). Example: https://openstreetmap.org/?mlat=51.477352&mlon=0.0If you want to specify the “zoom level” (i.e. how much of the map you can see), use
https://openstreetmap.org/?mlat<lat>&mlon=<lon>#map=<zoom>/<lat>/<lon>. Example: https://openstreetmap.org/?mlat=51.477352&mlon=0.0#map=19%2F51.447352%2F0.0There’s also osmand.net, which is more flexible. It asks you if you wish to open the location in an app, and if you do, you can use any app (whether it uses/supports OpenStreetMap or not), because it uses Android’s native location thingy for that. To use it, do
https://osmand.net/map/?pin<lat>,<lon>#<zoom>/<lat>/<lon>. Example: https://osmand.net/map/?pin=51.477352%2C0.0#19/51.477352/0.0