I wan't to reverse geocode and get the address in two languages arabic and english so I want to get it in one language then change the language of the API and get the address in the other language, as I can't find a parameter to send to geocoder to determine the language. Any suggestions?
相关问题
- How do you change the color of the dotted line on
- How do you change the color of the dotted line on
- draw polylines with different colors on v2 maps
- Add HTML class/ID to Google Maps Marker (API V3)
- Cannot resolve method “getMapAsync”
相关文章
- Avoiding “Sorry, we have no imagery here” with Goo
- Custom Marker performance iOS, crash with result “
- Google Map Gradient Polylines for Android?
- Angular 6 - @types/googlemaps/index.d.ts' is n
- Google Maps - Get Polygon border of zones/neighbor
- Google Map Marker Clickable Area
- getSupportFragmentManager().findFragmentById retur
- MapActivity cannot be resolved to a type
I created a function to change the language of Google Maps on the run.
Since it returns a
Promise
, you can easily wait until the API has loaded to execute some other code.Demo
Example of use
Documentation
Source
Demo
As already pointed out this can't be changed once the map is loaded, but, for those who can afford a page refresh, this could work:
HTML
JS
A language can be selected when you load the API by appending
language=XX
to the API URL whereXX
is the two-character language code (en
for English,ar
for Arabic, etc.) to the URL in the API call. See http://code.google.com/apis/maps/documentation/javascript/basics.html#Localization for documentation.This won't let you change it on the fly, and I don't think you can do that. You can try loading the API a second time after getting the initial info you need in one language. But that seems likely to cause problems.
A cleaner way to do it might be to create a separate page that acts as a sort of web service for you. It accepts two parameters: A language code and an address. It loads the API using the language code requested, and reverse geocodes the address, providing the result. Your page would call this web service-like thing twice, once for each language, and then use the results as desired.
The following example displays a map in Japanese and sets the region to Japan:
Source