How to indicate the language in the Google Maps API?

前端 未结 4 908
隐瞒了意图╮
隐瞒了意图╮ 2021-02-05 01:44

Just like you visit maps.google.com.tw or maps.google.co.kr or maps.google.co.jp, you can see their own language shown on every country. I

相关标签:
4条回答
  • 2021-02-05 02:11

    In Google Maps v3, you can use the "language" parameter:

    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&amp;language=en"></script>
    

    Language codes list: https://developers.google.com/maps/faq#languagesupport

    More info: http://googlegeodevelopers.blogspot.com/2009/10/maps-api-v3-now-speaks-your-language.html

    0 讨论(0)
  • 2021-02-05 02:26

    In Google Maps API v3, add "language" attribute to script tag. For example, the following will set map to display Russian in location names and navigation buttons:

    <script 
      src="http://maps.google.com/maps/api/js?sensor=false&amp;language=ru-RU"      
      type="text/javascript"></script> 
    

    Result:

    alt text

    0 讨论(0)
  • 2021-02-05 02:28

    language code is IETF language code:

    http://en.wikipedia.org/wiki/IETF_language_tag

    <script 
        src="http://maps.google.com/maps/api/js?sensor=false&amp;language=ru-RU"      
        type="text/javascript"></script> 
    
    0 讨论(0)
  • 2021-02-05 02:29

    For the V2 Maps API:

    You can add an optional hl parameter to the <script> tag when including the Google Maps API, specifying the domain language to use, as in the following example:

    <!DOCTYPE html>
    <html> 
    <head> 
        <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 
        <title>Localization of the Google Maps API</title> 
        <script src="http://maps.google.com/maps?file=api&v=2&sensor=false&hl=ko"
                type="text/javascript"></script> 
      </head> 
      <body onunload="GUnload()"> 
    
        <div id="map_canvas" style="width: 400px; height: 300px"></div> 
    
        <script type="text/javascript"> 
           var map = new GMap2(document.getElementById("map_canvas"));
           map.setCenter(new GLatLng(36.48, 128.00), 7);
           map.setUIToDefault();
        </script> 
      </body> 
    </html>
    

    Screenshot:

    Localization of the Google Maps API

    You may also want to check out the following resources for further reading:

    • Supported list of domain languages
    • Localization of the Google Maps API
    0 讨论(0)
提交回复
热议问题