-1

Following is the my code for getting direction detail..

<html> 
<head> 
   <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 
   <title>Google Maps API v3 Directions Example</title> 
   <script type="text/javascript" 
           src="http://maps.google.com/maps/api/js?sensor=false"></script>
</head> 
<body style="font-family: Arial; font-size: 12px;"> 
   <div style="width: 600px;">
     <div id="map" style="width: 280px; height: 400px; float: left;"></div> 
     <div id="panel" style="width: 300px; float: right;"></div> 
   </div>

   <script type="text/javascript"> 

     var directionsService = new google.maps.DirectionsService();
     var directionsDisplay = new google.maps.DirectionsRenderer();

     var map = new google.maps.Map(document.getElementById('map'), {
       zoom:7,
       mapTypeId: google.maps.MapTypeId.ROADMAP
     });

     directionsDisplay.setMap(map);
     directionsDisplay.setPanel(document.getElementById('panel'));

     var request = {
       origin: 'Chicago', 
       destination: 'New York',
       travelMode: google.maps.DirectionsTravelMode.DRIVING
     };

     directionsService.route(request, function(response, status) {
       if (status == google.maps.DirectionsStatus.OK) {
         directionsDisplay.setDirections(response);
       }
     });
   </script> 
</body> 
</html>

you can run this code in your browser.

enter image description here

Now i want to translate those direction information in other language like Greek, German, Russian, etc.. is there any option available in direction API to give language code and based on that it gives response.. i know Google translator is available but i don't know how to use it with it.

Please HELP !!

hardik
  • 9,141
  • 7
  • 32
  • 48

2 Answers2

4

If you already know the language you need prior to showing the map, you can load specific language maps:

<script type="text/javascript" 
        src="http://maps.googleapis.com/maps/api/js?sensor=false&language=ja">

There is also a list of supported languages per API version.

Erik Philips
  • 53,428
  • 11
  • 128
  • 150
2

Check out the localization documentation: https://developers.google.com/maps/documentation/javascript/basics#Localization

But basically, you must specify the language using a GET HTTP request:

<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false&language=ja">

Here is a spreadsheet of the supported languages: https://spreadsheets.google.com/pub?key=p9pdwsai2hDMsLkXsoM05KQ&gid=1

If you don't know the user's language at runtime, you may use the jQuery function $.getScript to request the script using the correct language, after prompting the user for the language to use.

jeff
  • 8,300
  • 2
  • 31
  • 43
  • 1
    Hey thnks for your answer, and thanks for $.getScript information.. i really appreciate your answer.. thank you again. – hardik Jul 06 '12 at 17:30