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

Not sure what's going on, but if I make a request to Nominatim from the browser for this address ( 5145 Beltway Drive, Grand Rapids ) like this then it work fine, but if I do it through php and wrap the city and street details in urlencode, then I get no response.

The encoded URL format is this, but somehow this is not accepted. The http response is 200, so that's not the issue.

Does it simply not accept encoded data? I can't find anything about it in the documentation.

asked 08 Jun '20, 19:09

Tijmens's gravatar image

Tijmens
16113
accept rate: 0%


The urlencode of a full URL also encodes = (as %3D) and I think &, too . What you probably want to do is urlencode the values only. E.g.

$street = '5145 Beltway Drive';
$city = 'Grand Rapids';
$url = 'https://nominatim.openstreetmap.org/search?street='.urlencode($street).'&city='.urlencode($city).'&format=json&addressdetails=1&limit=1';

For best results I suggest using the unstructured query format and add the country if possible. jsonv2 format also has a couple of additional field.

$address = $street . ', ' . $city . ', USA';
$url = 'https://nominatim.openstreetmap.org/search?q='.urlencode($address).'&format=jsonv2&addressdetails=1&limit=1';
permanent link

answered 08 Jun '20, 20:37

mtmail's gravatar image

mtmail
4.8k1574
accept rate: 27%

edited 08 Jun '20, 20:37

Your answer
toggle preview

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:

×689

question asked: 08 Jun '20, 19:09

question was seen: 1,461 times

last updated: 08 Jun '20, 20:37

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