A
A
Alex Ant2017-01-05 18:32:04
JavaScript
Alex Ant, 2017-01-05 18:32:04

How to get geocoding in one language?

In a Yii2 project, I use a widget based on jquery-locationpicker-plugin .

It is necessary to record the geographical location of the Country-City in the database based on the coordinates received from the user and do this in one language (English). The widget returns me the name of the location depending on the country: Germany - in German, Finland - in Finnish, etc. How can I force data collection in one language? I looked at the documentation, but I did not see such a thing there, although .. it must be, I guess. Who will tell?


echo $form->field($model, 'coordinates')->widget('\pigolab\locationpicker\CoordinatesPicker' , [
...
'oninitialized' => new JsExpression($js1),
'onchanged' => new JsExpression ($js2),
...
]);
'


$js = '
function(c){
var addressComponents = jQuery(c).locationpicker("map").location.addressComponents;
......
});
'


$js2= '
function (currentLocation, radius, isMarkerDropped) {
var addressComponents = $(this).locationpicker("map").location.addressComponents;
$("#street").val(addressComponents.addressLine1);
$("#city").val(addressComponents.city);
$("#state").val(addressComponents.stateOrProvince);
$("#country").val(addressComponents.country);
'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2017-01-05
@webinar

use (get) only coordinates, numbers do not depend on the language, and then use them to get names through the same google maps api:
https://developers.google.com/places/javascript/
or parse js and add localization to it:
https://developers.google.com/maps/documentation/j...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question