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

Display a map with a pin on it by passing parameters in the URL

1

I would like to know if it is possible to display a map with a pin by passing the address data in the URL? That means: I dont know latitude and longitude of the address I want to display, I just know City, zipcode, street and housenumber.

asked 16 Apr '20, 12:06

normannescio's gravatar image

normannescio
26223
accept rate: 0%


2 Answers:

2

You'll find a lot of relevant information in this recent question.

Simple answer is https://www.openstreetmap.org/search?query= , but it has limitations.

Regards

answered 16 Apr '20, 14:10

H_mlet's gravatar image

H_mlet
5.4k1781
accept rate: 13%

1

You can search by address by appending search?query= to the URL, like this:

https://www.openstreetmap.org/search?query=221b%20Baker%20Street%20London

...but that won't show a marker on the map, at least until you hover the mouse over one of the Nominatum results.

You can add a marker to the map by specifying latitude and longitude with mlat and mlon parameters:

https://www.openstreetmap.org/?mlat=39.9155&mlon=4.1745

...but there's no way to do that with just an address.

However, if you're willing to do a two-step process, you can first query by address to get coordinates (you can use the Nominatum API directly, or just use the search?query= method and pull the top result's coordiates from the redirected URL after the #map= string) and then construct a marker URL with the mlat and mlon parameters.

answered 16 Apr '20, 19:34

jmapb's gravatar image

jmapb
3.4k73361
accept rate: 22%

edited 16 Apr '20, 20:27

Source code available on GitHub .