php-extended/php-openstreetmap-nominatim-api

A php API wrapper to connect to nominatim.openstreetmap.com API


Keywords
php, api, wrapper, nominatim, OpenStreetMap
License
MIT

Documentation

php-openstreetmap-nominatim-api

A php API wrapper to connect to nominatim.openstreetmap.com API

Installation

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.

Basic Usage

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();

License

MIT (See license file).