Geocoder
Geocoder copied to clipboard
[Google Maps] Add output language support
The following was submitted in the GeocoderLaravel repo by @xSoulRootx (https://github.com/geocoder-php/GeocoderLaravel/issues/144), but probably belongs here:
============
General Information
GeocoderLaravel Version: ^4.0 Laravel Version: 5.7.* PHP Version: 7.2 Operating System and Version: Ubuntu
Issue Description
Output language in reverse query don't work
Resolve
vendor\geocoder-php\google-maps-provider\GoogleMaps.php
in
public function reverseQuery(ReverseQuery $query): Collection
before
return $this->fetchUrl($url, $query->getLocale(), $query->getLimit(), $query->getData('region', $this->region));
add
if (null !== $query->getLocale()) {
$url .= '&result_type='.urlencode($resultType);
} else {
$url .= '&language='.env('GOOGLE_MAPS_LOCALE', 'en-US');
}
or something like this
I had a look at this issue, and it seems to be working correctly.
The value of $url
that is fetched is
https://maps.googleapis.com/maps/api/geocode/json?latlng=48.863151,2.388911&language=fr-FR&key=AIzaSyBQIXT2Vp5pQpGuOJWBuH68sIc7ZeBbSQ8
Which correctly contains the language
param set here:
https://github.com/geocoder-php/Geocoder/blob/master/src/Provider/GoogleMaps/GoogleMaps.php#L158-L160
Am I missing the issue here?
On a side note, most of the google maps tests are failing 🤔
Sorry, deleted my comment, I mistakenly thought I was in the other repo.
@mikebronner
Seems 10 tests are failing:
I'll create a PR to fix them when I have a chance.
@xSoulRootx
Can you verify that you were setting the locale and it is working?
@xSoulRootx
Can you verify that you were setting the locale and it is working