Skip to content

Commit 9715af7

Browse files
committed
Some documentation about Photon Geocoder
1 parent 9089dae commit 9715af7

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

src/Provider/Photon/Readme.md

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,46 @@
1010
This is the photon provider from the PHP Geocoder. This is a **READ ONLY** repository. See the
1111
[main repo](https://github.com/geocoder-php/Geocoder) for information and documentation.
1212

13-
### Install
14-
13+
## Install
1514
```bash
1615
composer require geocoder-php/photon-provider
1716
```
1817

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+
```
2052

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
2255
report any issues you find on the [issue tracker](https://github.com/geocoder-php/Geocoder/issues).

0 commit comments

Comments
 (0)