-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use different geocoders #47
Comments
How should the |
@hohl, that's exactly what I did yesterday. Upgraded to the php version of geocoder, and it ended up being even easier to use than this one. While I appreciate the work done on this package, it being out of date is actually starting to cause problems (which were aleviated as soon as I implemented the current php package). Here is the trait I use on my models that need it (sure, can use some refactoring, but it shows how easy it is to implement). <?php namespace App\Traits;
use Geocoder\Provider\GoogleMaps;
use Ivory\HttpAdapter\CurlHttpAdapter;
use Illuminate\Support\Collection;
trait Geocodable
{
public function geocode(string $address) : Collection
{
$adapter = new CurlHttpAdapter();
$geocoder = new GoogleMaps($adapter);
return collect($geocoder->geocode($address)->all());
}
} |
Working on new release ... will add example to documentation on making this work with the chain provider. |
Having researched this some more, this will require a separate PR. However, I would like to implement it, as I think its increadibly useful. I will submit a PR to the parent repo, and if that is rejected, implement it locally for the laravel repo (however, that might cause some oddities as we would have diverging functionality, something we should avoid). If anyone wants to help out with this, please submit a PR to the main geocoder repo and reference this issue, if I don't get to it first, or if one hasn't already been created. |
Figured out a better solution requiring no additional PR. Will be in next release. Please keep an eye on this and re-open if it happens again after release. Thanks :) |
Sometimes I want to geocode IP addresses of my users and sometimes I want to geocode addresses. For the IP addresses I would like to use the
FreeGeoIpProvider
, for the addresses I would like to use theGoogleMapsProvider
. Is there any way to switch between the configured providers in code?I've seen there is a method called
using
in theGeocode
facade. However, I couldn't get it working.The text was updated successfully, but these errors were encountered: