GeocoderLaravel | Geocoder service provider for Laravel | Build Tool library
kandi X-RAY | GeocoderLaravel Summary
kandi X-RAY | GeocoderLaravel Summary
Geocoder service provider for Laravel
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Cache a request .
- Dumps results .
- Get the providers from the configuration .
- Get arguments .
- Get the config path .
- Register the Geocoder class .
- Bootstrap the package .
- Gets the facade accessor .
- Provide a list of geocoder .
GeocoderLaravel Key Features
GeocoderLaravel Examples and Code Snippets
Community Discussions
Trending Discussions on GeocoderLaravel
QUESTION
https://github.com/geocoder-php/GeocoderLaravel/blob/master/config/geocoder.php I cant get pass this point. 1. this is my Job
public $model;
public function __construct($model)
{
$this->model = $model;
}
public function handle()
{
$result = new Geocoder();
$result->geocode($this->model->getAddressString());
// $result = Geocoder::geocode($this->model->getAddressString());
$this->model->setCoordinates($result->getLatitude(), $result->getLongitude());
}
}
I followed the instructions in the repo readme to install geocoder into my project.
2. this is my controller
...ANSWER
Answered 2019-Jun-04 at 11:34public function handle()
{
$users = User::whereNull('lat')->whereNull('lng')->whereNull('city')->whereNull('state')->whereNull('address')->get();
foreach ($users as $user)
{
$response = Geocode::make()->address($user->zipcode);
if ($response){
$lat = $response->latitude();
$lng = $response->longitude();
$city = $response->raw()->address_components[1]->long_name;
$state = $response->raw()->address_components[2]->long_name;
$address = $response->formattedAddress();
echo $response->locationType();
DB::table('users')->where('id', $user->id)->update(['lat' => $lat, 'lng' => $lng, 'city' => $city, 'state' => $state, 'address'=> $address]);
}
}exit;
}
QUESTION
I'm wanting to reverse geocode coordinate to get the address using Geocoder-php. I'm able to get the Address Collection using $geo = app('geocoder')->reverse($lat, $lng)->get()
.
According to these docs found on github for Geocoder-php you can retrieve the properties form the collection, such as street name by using $geo->getStreetName()
, the city by using $geo->getCity()
, the country by using $geo->getCountry()
, etc, but there are no methods for returning the State or Province.
How do I grab the state or province from the collection?
I can see the province when I use $geo->getAdminLevels()->get()
. Which returns
ANSWER
Answered 2019-Apr-16 at 06:30The solution to this is to call it this way;
QUESTION
I wanted to use this package for geocoding in Laravel. I have added it to providers and published the config, but I am getting trouble setting it up to work.
...ANSWER
Answered 2017-Dec-12 at 14:41did you try using dd() in tinker?? I have been try it...and it work for me..
try this :
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install GeocoderLaravel
Install the package via composer:
If you are running Laravel 5.5 (the package will be auto-discovered), skip this step. Find the providers array key in config/app.php and register the Geocoder Service Provider:
Optional I recommend adding the following lines to your composer.json file to prevent stale caches when upgrading or updating the package, both in your live and dev environments:
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page