<html>
<head>
<script src="http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places&language=pt-PT" type="text/javascript"></script>
<script type="text/javascript">
function initialize() {
var request = {
placeId: 'ChIJO_PkYRozGQ0R0DaQ5L3rAAQ'
};
service = new google.maps.places.PlacesService(document.getElementById('places'));
service.getDetails(request, callback);
function callback(place, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
console.log(place);
}
}
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body> <div id="places"></div> </body>
</html>
I have this code that works well, but i don't know why i need to use
PlacesService(document.getElementById('some id'));
If i use only PlacesService();
I will get an error. The html_attributions is none: html_attributions: Array[0]length: 0
So, is my code fine, or what should I do?
http://jsfiddle.net/c6p14g4d/