You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-1Lines changed: 28 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -308,6 +308,33 @@ Parameters:
308
308
*`$useSsl` is available for `GoogleMapsProvider`, `GoogleMapsBusinessProvider`, `MaxMindProvider` and `ArcGISOnlineProvider`.
309
309
*`$sourceCountry` is available for `ArcGISOnlineProvider`.
310
310
311
+
312
+
### Using The ChainProvider ###
313
+
314
+
As said it's a special provider that takes a list of providers and iterates over this list to get information. Note
315
+
that it **stops** its iteration when a provider returns a result. The result is returned by `GoogleMapsProvider`
316
+
because `FreeGeoIpProvider` and `HostIpProvider` cannot geocode street addresses. `YahooProvider` is ignored.
317
+
318
+
```php
319
+
$geocoder = new \Geocoder\Geocoder();
320
+
$adapter = new \Geocoder\HttpAdapter\CurlHttpAdapter();
321
+
$chain = new \Geocoder\Provider\ChainProvider(array(
322
+
new \Geocoder\Provider\FreeGeoIpProvider($adapter),
323
+
new \Geocoder\Provider\HostIpProvider($adapter),
324
+
new \Geocoder\Provider\GoogleMapsProvider($adapter, 'fr_FR', 'France', true),
325
+
new \Geocoder\Provider\YahooProvider($adapter, '<API_KEY>', 'fr_FR'),
326
+
// ...
327
+
));
328
+
$geocoder->registerProvider($chain);
329
+
330
+
try {
331
+
$geocode = $geocoder->geocode('10 rue Gambetta, Paris, France');
332
+
var_export($geocode);
333
+
} catch (Exception $e) {
334
+
echo $e->getMessage();
335
+
}
336
+
```
337
+
311
338
Everything is ok, enjoy!
312
339
313
340
API
@@ -526,7 +553,7 @@ You can also write your own `provider` by implementing the `ProviderInterface`.
526
553
527
554
You can provide your own `result` by extending `ResultFactory` and implementing `ResultInterface` if your provider returns more informations than the default one.
528
555
529
-
Note, `AbstractProvider` and `AbstractResult`clasess can help you by providing useful features.
556
+
Note, `AbstractProvider` and `AbstractResult`classes can help you by providing useful features.
530
557
531
558
You can provide your own `dumper` by implementing the `DumperInterface`.
0 commit comments