Closed madn3z closed 5 years ago
@madn3z Hi, thanks for writing in. Your $geocode
is a collection. It has no idea of the coordinates, because it may contain many results. This should work:
$geocode->first()->getLatitude();
@mikebronner I did the test with what you told me, but now I throw another error.
message: "Call to undefined method Geocoder\Provider\GoogleMaps\Model\GoogleAddress::getLatitude()",…}
exception: "Symfony\Component\Debug\Exception\FatalThrowableError"
file: "C:\xampp\htdocs\vuesax\app\Http\Controllers\EmpresaController.php"
line: 221
message: "Call to undefined method Geocoder\Provider\GoogleMaps\Model\GoogleAddress::getLatitude()"
@mikebronner I solved my problem, I was missing the following.
$geocode->getCoordinates()->getLatitude()
Thank you very much for your help.
Good find! I was about to reply with the same answer, you can view the Address model: https://github.com/geocoder-php/Geocoder/blob/master/src/Common/Model/Address.php
General Information
GeocoderLaravel Version: 4.2 Laravel Version: 5.8 PHP Version: 7.1.3 Operating System and Version: Windows
Issue Description
I am trying to get latitude and longitude with the following code, but it tells me that the "getLatitude" or "getLongitude" method does not exist.
error:
with dd($geocode) the following appears to me: