如何通过getDetails以特定语言获取地点详细信息?

时间:2015-06-08 08:57:44

标签: google-places-api

有了placeId,我需要获取地方详细信息。我可以使用以下代码执行此操作:

        var service = new google.maps.places.PlacesService(document.createElement("div"));
        service.getDetails({
            placeId: locationReference
        }, parseLocationDetailResponse.bind(null, function(addressObject) {
            deferred.resolve(addressObject);
        }));

如何手动指定地点详细信息对象的语言?

1 个答案:

答案 0 :(得分:1)

Google地图提供您需要的list种语言。在脚本&language=(type of language)

中简单添加scr

function initialize() {
  var mapOptions = {
    zoom: 8,
    center: new google.maps.LatLng(-34.397, 150.644)
  };
  var map = new google.maps.Map(document.getElementById('map-canvas'),
      mapOptions);
}

google.maps.event.addDomListener(window, 'load', initialize);
 html, body, #map-canvas {
        height: 100%;
        margin: 0px;
        padding: 0px
      }
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&language=ja"></script>
<div id="map-canvas"></div>