|
10 | 10 | This is the photon provider from the PHP Geocoder. This is a **READ ONLY** repository. See the
|
11 | 11 | [main repo](https://github.com/geocoder-php/Geocoder) for information and documentation.
|
12 | 12 |
|
13 |
| -### Install |
14 |
| - |
| 13 | +## Install |
15 | 14 | ```bash
|
16 | 15 | composer require geocoder-php/photon-provider
|
17 | 16 | ```
|
18 | 17 |
|
19 |
| -### Contribute |
| 18 | +## API Documentation |
| 19 | +https://photon.komoot.io |
| 20 | +https://github.com/komoot/photon |
| 21 | + |
| 22 | +## Usage |
| 23 | + |
| 24 | +### Basic usage |
| 25 | +You can use your own photon instance : |
| 26 | +```php |
| 27 | +// New instance of the provider : |
| 28 | +$provider = new Geocoder\Provider\Photon\Photon($httpClient, 'https://your-photon-root-url'); |
| 29 | +// Run geocode or reverse query |
| 30 | +$query = $provider->geocodeQuery(new \Geocoder\Query\GeocodeQuery('Paris')); |
| 31 | +$reverseQuery = $provider->reverseQuery(\Geocoder\Query\ReverseQuery::fromCoordinates(48.86036 ,2.33852)); |
| 32 | +``` |
| 33 | + |
| 34 | +### OSM Tag Feature |
| 35 | +You can search for location data based on osm tag filters. |
| 36 | + |
| 37 | +For example, you can filter a geocode query to only include results of type 'place'. You can even restrict it to only have places of type 'city'. |
| 38 | + |
| 39 | +In the reverse geocoding context you can search for the 3 pharmacies closest to a location. |
| 40 | + |
| 41 | +To see what you can do with this feature, check [the official photon documentation](https://github.com/komoot/photon#filter-results-by-tags-and-values) |
| 42 | + |
| 43 | +Below is an example to query the 3 pharmacies closest to a location : |
| 44 | +```php |
| 45 | +$provider = new Geocoder\Provider\Photon\Photon($httpClient, 'https://your-photon-root-url'); |
| 46 | +$reverseQuery = ReverseQuery::fromCoordinates(52.51644, 13.38890) |
| 47 | + ->withData('osm_tag', 'amenity:pharmacy') |
| 48 | + ->withLimit(3); |
| 49 | + |
| 50 | +$results = $provider->reverseQuery($reverseQuery); |
| 51 | +``` |
20 | 52 |
|
21 |
| -Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or |
| 53 | +## Contribute |
| 54 | +Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or |
22 | 55 | report any issues you find on the [issue tracker](https://github.com/geocoder-php/Geocoder/issues).
|
0 commit comments