A php API wrapper to connect to nominatim.openstreetmap.com API
A php API wrapper to connect to nominatim.openstreetmap.com API
The installation of this library is made via composer.
Download composer.phar
from their website.
Then add to your composer.json :
"require": {
...
"php-extended/php-openstreetmap-nominatim-api": "~1",
...
}
Then run php composer.phar update
to install this library.
The autoloading of all classes of this library is made through composer's autoloader.
This library may be used the following way :
use PhpExtended\OpenStreetMap\OpenStreetMapNominatimApiRequest;
use PhpExtended\OpenStreetMap\OpenStreetMapNominatimApiEndpoint;
$processor = '<put here your \PhpExtended\HttpProcessor\ProcessorInterface>';
$url = '<put here the nominatim api url>';
$userAgent = '<put here the user agent of your application>';
$api = new OpenStreetMapNominatimApiEndpoint($processor, $url, $userAgent);
$request = new OpenStreetMapNominatimApiRequest();
$request->setQuery('Eiffel Tower, Paris');
$request->setEmail('<put here a valid email address>');
$response = $api->searchGeocode($request);
/* @var $response \PhpExtended\OpenStreetMap\OpenStreetMapNominatimApiGeocodingResult */
echo $response->getLatitude().' '.$response->getLongitude();
MIT (See license file).