Reputation: 75
Imagine I have latitude and longitude in my html file. First, I want google API javascript code to get the city and country name from this latitude and longitude. I made it. What I want to accomplish is, I want to get this city and country name in the specific language. for example I have latitude: 41.23123 and longitude:45.123123 When I transfer these to city name I get tsereteli avenue. As you know this is english. I want to get it in russian text. How do I do that?
Upvotes: 0
Views: 1910
Reputation: 2156
You need to add the language parameter in the url (supposing you are using JSON get API)
$(document).ready(function(){
var latitude = 73.59852;
var longitude = 55.40842;
//Set your Language
var language = "ru";
var url = "http://maps.googleapis.com/maps/api/geocode/json?latlng="+latitude+","+longitude+"&sensor=true&language="+language;
$.ajax({
type: 'GET',
url: url,
success: function(data){
alert(JSON.stringify(data));
}
});
});
Documentation here
Upvotes: 1
Reputation: 6143
From google maps documentation
By default, the Google Maps JavaScript API uses the user's preferred language setting as specified in the browser, when displaying textual information
if you want the Maps JavaScript API to ignore the browser's language setting, you can force it to display information in a particular language by adding a language parameter to the <script>
tag
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&language=ru®ion=RU">
</script>
here ru
is ISO Language Codes for Russian
Upvotes: 1