geocoder-php / arcgis-online-provider
Geocoder ArcGIS Online adapter
Installs: 357 646
Dependents: 3
Suggesters: 1
Security: 0
Stars: 4
Watchers: 2
Forks: 2
pkg:composer/geocoder-php/arcgis-online-provider
Requires
- php: ^8.0
- geocoder-php/common-http: ^4.0
- willdurand/geocoder: ^4.0|^5.0
Requires (Dev)
- geocoder-php/provider-integration-tests: ^1.6.3
- php-http/message: ^1.0
- phpunit/phpunit: ^9.5
Provides
README
This is the ArcGIS provider from the PHP Geocoder. This is a READ ONLY repository. See the main repo for information and documentation.
ArcGIS provides 2 APIs for geocoding addresses:
- geocodeAddresses
- findAddressCandidates- This API states:
 - Applications are contractually prohibited from storing the results of geocoding transactions unless they make the request by passing the - forStorageparameter with a value of- trueand the- tokenparameter with a valid ArcGIS Online token.
Since a token is required for the geocodeAddresses API, the
geocodeQuery method checks the token property:
- If tokenisNULL, it uses thefindAddressCandidatesAPI.
- If tokenis notNULL, it uses thegeocodeAddressesAPI.- If the tokenvalue is invalid or has expired, you will get an error.
- Tokens have a maximum lifetime of 14 days.
- Instructions for generating an ArcGIS token
 
- If the 
Usage
Without a token
$httpClient = new \Http\Discovery\Psr18Client(); $provider = new \Geocoder\Provider\ArcGISList\ArcGISList($httpClient); // Uses the `findAddressCandidates` operation. Result storage is prohibited. $result = $geocoder->geocodeQuery(GeocodeQuery::create('Buckingham Palace, London'));
With a token
$httpClient = new \Http\Discovery\Psr18Client(); // Your token is required. $provider = \Geocoder\Provider\ArcGISList\ArcGISList::token($httpClient, 'your-token'); // Uses the `geocodeAddresses` operation. Result storage is permitted. $result = $geocoder->geocodeQuery(GeocodeQuery::create('Buckingham Palace, London'));
Install
composer require geocoder-php/arcgis-online-provider
Note
It is possible to specify a sourceCountry to restrict results to this specific
country thus reducing request time (note that this doesn't work on reverse
geocoding).
Contribute
Contributions are very welcome! Send a pull request to the main repository or report any issues you find on the issue tracker.