Skip to content

Cannot access private property when trying to access Google Maps results #56

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

Closed
jryd opened this issue Nov 23, 2016 · 1 comment
Closed

Comments

@jryd
Copy link

jryd commented Nov 23, 2016

I am using this to geocode an address and dump the results so I can see them:

$geocode = app('geocoder')->geocode('Los Angeles, CA')->get();
dd($geocode);

this works fine and I can see that it was successful as I can see all the geocoded results for LA.

When I try to begin accessing the results I get this error

Cannot access private property Geocoder\Model\AddressCollection::$addresses

This is using dd($geocode->addresses).

Ultimately I just want to get the latitude and longitude from my gecoded address - how do I do this?

@mikebronner
Copy link
Member

This might be one way of doing it:

$geocode = app('geocoder')->geocode('Los Angeles, CA')->get();
$latitude = $geocode->first()->getLatitude();
$longitude = $geocode->first()->getLongitude();

The items in geocode results collection use getters to retrieve values, instead of public properties.
Here is the relevant documentation: https://github.com/geocoder-php/Geocoder#address--addresscollection.

Hope this helps you out a bit. Please feel free to re-open if you continue to have issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants