问题
Having placeId I need to get place details. I can do this with the following code:
var service = new google.maps.places.PlacesService(document.createElement("div"));
service.getDetails({
placeId: locationReference
}, parseLocationDetailResponse.bind(null, function(addressObject) {
deferred.resolve(addressObject);
}));
How can I manually specify language for place details object?
回答1:
Google maps provides list of languages you need. Simple adding the &language=(type of language) in script 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>
来源:https://stackoverflow.com/questions/30704931/how-can-i-get-place-details-via-getdetails-in-specific-language