PHP code example of opendi / nominatim
1. Go to this page and download the library: Download opendi/nominatim library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once ('vendor/autoload.php' );
opendi / nominatim example snippets
use Opendi \Nominatim \Nominatim ;
$url = "http://nominatim.openstreetmap.org/" ;
$nominatim = Nominatim::newInstance($url);
$search = $nominatim->newSearch();
$search->query('1600 Pennsylvania Ave NW, Washington, DC 20500, United States' );
$nominatim->find($search);
$search = $nominatim->newSearch()
->street('1600 Pennsylvania Ave NW' )
->city('Washington' )
->county('Washington' )
->state('Washington DC' )
->postalCode('DC 20500' )
->country('United States' )
->addressDetails();
$nominatim->find($search);
Array
(
[0 ] => Array
(
[place_id] => 2632584431
[licence] => Data © OpenStreetMap contributors, ODbL 1.0 . http:
[osm_type] => way
[osm_id] => 238241022
[boundingbox] => Array
(
[0 ] => 38.8974898
[1 ] => 38.897911
[2 ] => -77.0368539
[3 ] => -77.0362521
)
[lat] => 38.8976989
[lon] => -77.036553192281
[display_name] => The White House, 1600 , Pennsylvania Avenue Northwest, Thomas Circle, Southwest Waterfront, Washington, 20500 , United States of America
[class ] => tourism
[type ] => attraction
[importance ] => 1.5576757387296
[icon ] => http ://nominatim .openstreetmap .org /images /mapicons /poi_point_of_interest .p .20.png
[address ] => Array
(
[attraction ] => The White House
[house_number ] => 1600
[pedestrian ] => Pennsylvania Avenue Northwest
[neighbourhood ] => Thomas Circle
[suburb ] => Southwest Waterfront
[city ] => Washington
[county ] => Washington
[postcode ] => 20500
[country ] => United States of America
[country_code ] => us
)
)
)