Why not ask your question on the new OpenStreetMap Community Forum?

Hello everybody,

I'm writing a planning application, witch has a database of place the users may have to go to. This application offer the users the ability the view a place he has to go to on a map website.

Actually my app can do it by showing a link to an map website, for example mith gmap https://www.google.com/maps/place/[HOUSE_NUMBER]%20[STREET_NAME],[ZIP]+[CITY]

I don't like to promote GAFAMS and would prefer to promote openstreetmap by directing users to it instead of google.

I searched but didn't found a way to do exactly the same thing with OSM, just by generating an url containing the adresse of the place.

I know that i can build an URL to tell OSM to directly generate a map centred on a given point an a map by giving it it's coordinates. (for exemple: https://www.openstreetmap.org/?mlat=43.59021&mlon=1.40741#map=17/43.59021/1.40741), but i don't know the coordinates, and would like openstreetmap to search it from the adress

I know that i can build an URL telling openstreetmap to search for an adress like https://www.openstreetmap.org/search?query=[HOUSE_NUMBER]%20[STREET_NAME]%2C%20[CITY], but when i do that, openstreetmap will open a list of results, not show the most relevant one directly on the map.

Is there a way to build on URL to tell him "search for this adress, and show the most relevant result on the map putting a marker on it"?

Or do I need to write some "wrapper" PHP script taking address as argument, search the coordinates on nominatim, and returning a 302(redirect) to an URL telling openstreetmap to show these coordinates?

Thanks for help,

Julien Marin

asked 14 Dec '19, 12:28

ptitnuage's gravatar image

accept rate: 0%

edited 15 Dec '19, 12:41

SimonPoole's gravatar image

SimonPoole ♦

You should be using nominatim https://nominatim.openstreetmap.org/ to do this (or photon if you need a slightly fuzzy search frontend to it).

The big caveat is that this will only work well when relevant address information is present in our data.

permanent link

answered 15 Dec '19, 12:36

SimonPoole's gravatar image

SimonPoole ♦
accept rate: 18%

Thanks for the answer i didn't knew about photo and fuzzzy, search, it's a big relief...

I will write a script requesting for coordinates then doing

$url="https://www.openstreetmap.org/?mlat=$lat&mlon=$lon#map=$zoom/$lat/$lon"; header("Location: $url");

Have a good day!


(15 Dec '19, 12:50) ptitnuage
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 14 Dec '19, 12:28

question was seen: 9,208 times

last updated: 15 Dec '19, 12:50

powered by OSQA