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

How to access a specific map using the name of a city or location in the url?

1

Hi,

I'm using Openstreetmap to show the location of faculties on a map. Now, is there any way to pass a url with the name of the location and to get embeddable html code for the location on the map?

For example:

<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" 
marginwidth="0" src="https://www.openstreetmap.org/export/embed.html?
  bbox=18.396367,43.855225,18.40038,43.858146&amp;layer=mapnik"
style="border: 1px solid black"></iframe><br />
<small><a href="https://www.openstreetmap.org/?lat=43.8566855&amp;
   lon=18.3983735&amp;zoom=17&amp;layers=M">View Larger Map</a></small>

So, is there any way to pass the name of the location in a url, because I would like to show maps dynamically (based on location from a mysql table).

Thanks in advance,

Amer

asked 18 Apr '11, 11:57

aldm's gravatar image

aldm
31223
accept rate: 0%

edited 19 Apr '11, 09:33

sleske's gravatar image

sleske
4.1k135678


One Answer:

1

No, there is no direct way to to this as far as I know. It would be difficult to imagine how this should work, because often location names will be ambiguous (there are even cities with multiple streets with identical names).

What you can do is use a geolocation service (such as Nominatim) to get the coordinates of a place, then use that to display the map. Nominatim for example can be queried over the web (the wiki page lists the URLs and parameters).

Finally, if the list of locations to be shown is known in advance (there are only so many faculties, after all), it's probably easier to get the coordinates once (possibly by hand), then use them directly.

answered 19 Apr '11, 09:42

sleske's gravatar image

sleske
4.1k135678
accept rate: 24%

Source code available on GitHub .