Geocoder icon indicating copy to clipboard operation
Geocoder copied to clipboard

[Google Maps] Add output language support

Open mikebronner opened this issue 5 years ago • 5 comments

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

mikebronner avatar Mar 04 '19 17:03 mikebronner

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?

atymic avatar Jun 24 '19 23:06 atymic

On a side note, most of the google maps tests are failing 🤔

atymic avatar Jun 24 '19 23:06 atymic

Sorry, deleted my comment, I mistakenly thought I was in the other repo.

mikebronner avatar Jun 24 '19 23:06 mikebronner

@mikebronner Seems 10 tests are failing: Screen Shot 2019-06-25 at 9 14 29 am

I'll create a PR to fix them when I have a chance.

atymic avatar Jun 24 '19 23:06 atymic

@xSoulRootx

Can you verify that you were setting the locale and it is working?

atymic avatar Jun 25 '19 22:06 atymic

@xSoulRootx

Can you verify that you were setting the locale and it is working

atymic avatar Aug 25 '19 23:08 atymic