Add output language support
xSoulRootx opened this issue · 2 comments
xSoulRootx commented
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 commented
@xSoulRootx I reposted your issue here: geocoder-php/Geocoder#940
Please follow up with it there, as it relates to the underlying package, and not this package. :) Good luck!
andreshg112 commented
This is already implemented but not documented.
$query = \Geocoder\Query\ReverseQuery::fromCoordinates($this->latitude, $this->longitude)
->withData('language', 'es-419')
->withData('result_type', 'street_address|route|political');
/** @var \Illuminate\Support\Collection $results */
$results = \Geocoder\Laravel\Facades\Geocoder::reverseQuery($query)->get();
if ($results->count() > 0) {
/** @var \Geocoder\Provider\GoogleMaps\Model\GoogleAddress $first */
$first = $results->first();
$value = $first->getFormattedAddress();
}