SIMPLE reverse geocoding using Nominatim
Posted
by
tony gil
on Stack Overflow
See other posts from Stack Overflow
or by tony gil
Published on 2012-06-06T23:32:57Z
Indexed on
2012/06/07
10:40 UTC
Read the original article
Hit count: 385
i am developing an online mapping application using OpenLayers + OpenStreetMaps.
i need help implementing a simple reverse geocoding function in javascript (or php) that receives Latitude and Longitude and returns an Address.
i would like to work with Nominatim, if possible. i do NOT want to use Google, Bing or CloudMade or other proprietary solutions.
this link returns a reasonable response and i used simple_html_dom.php to break down the result but it is sort of an ugly solution.
<?php
include('simple_html_dom.php');
$url = "http://nominatim.openstreetmap.org/reverse?format=xml&lat=-23.56320001&lon=-46.66140002&zoom=27&addressdetails=1";
$html = file_get_html($url);
foreach ($html->find('road') as $element ) {
echo $element;
}
?>
any suggestions of a more elegant solution?
© Stack Overflow or respective owner