This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Embed a link with marker

0
1

I have some links to Google Maps that I want to replace with OpenStreetMap ones. They are of this form. I can enter the postcode into OSM, zoom in to show individual buildings, Share and 'include marker' to get a link like this It looks much better than the Google version. Only problem, I have 200 of them to convert! Is there a way to generate the OSM links from the UK postcode? Looking up the lat/long coords for each would be a pain and would require some scripting, and ideally I can generate usable OSM links by inserting the postcode itself. But whenever and whatever I try, I don't get a permanently visible marker, and the zoom level is great for mountain ranges, not so much for the individual streets I'm interested in.

asked 26 Apr '21, 17:18

AdrianHB's gravatar image

AdrianHB
11112
accept rate: 0%

Well, I can only conclude that this forum is very inactive!

I think therefore that the answer is 'no', and that the solution requires the postcode to be replaced by its lat/lon coordinates. I think I have a practical way to do this and will post it here when I've tested it.

(01 May '21, 11:52) AdrianHB
1

Similar questions within the last month:

April 24th: https://help.openstreetmap.org/questions/79846/how-to-find-the-latitude-and-longitude-of-a-city

April 13th: https://help.openstreetmap.org/questions/79638/how-do-i-get-a-list-of-coordinates

UK postcodes are particularly patchy in OSM as they are rarely signposted and there often seem to be issues with the "open" database releases.

(01 May '21, 14:51) InsertUser

One Answer:

0

This is what I did! There were 1200 postcodes not 200, but this is seemed appropriate technology for the task.

I extracted the postcodes, one to a line.

I pasted them into Chris Bell's excellent Batch Geocoder, selecting Comma-separated and Input postcode, to give output lines of the form "AB24 3TU",57.166749,-2.104203

I converted these with find-and-replace in an editor into the PHP code for an associative array and wrote a PHP script to insert map links in the format https://www.openstreetmap.org/?mlat=$lat&mlon=$lon#map=17/$lat/$lon where 17 is the zoom level and $lat and $lon are the values in the second and third CSV fields.

Obviously there are many other ways to get the same result but this worked for a one-off job of finite size.

answered 01 May '21, 22:12

AdrianHB's gravatar image

AdrianHB
11112
accept rate: 0%

Source code available on GitHub .