NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the 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

ptitnuage
21112
accept rate: 0%

edited 15 Dec '19, 12:41

SimonPoole's gravatar image

SimonPoole ♦
44.7k13326701


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 ♦
44.7k13326701
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!

julien

(15 Dec '19, 12:50) ptitnuage

Follow this question

By Email:

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

By RSS:

Answers

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:

×535
×202
×147
×39
×9

question asked: 14 Dec '19, 12:28

question was seen: 11,613 times

last updated: 15 Dec '19, 12:50

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum