0
Google 장소가있는 객체에 대한 세부 정보를 받아야합니다. 나는이 쓰기 때문에 나는 opening_hours 필요 : 내 코드에 SOGoogle 장소에서 세부 정보보기
을 나는 장소, 서비스에 대한 요청을 추가하고 getDetails는
markers = [];
var bounds = new google.maps.LatLngBounds();
for (var i = 0, place; place = places[i]; i++) {
var image = {
url: place.icon,
size: new google.maps.Size(71, 71),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(17, 34),
scaledSize: new google.maps.Size(25, 25)
};
//CODE THAT I WRITE TO GET DETAILS FOR PLACE
var request = {
reference: place.reference
};
var service = new google.maps.places.PlacesService(map);
service.getDetails(request, function (place, status) {
var open = '';
try {
open = place.opening_hours.periods[1].open.time;
} catch (e) {
open = 'No work time';
}
var otvoreno = place.openNow + "</br>" + place.name;
// Create a marker for each place.
var marker = new MarkerWithLabel({
map: map,
icon: image,
title: place.name,
position: place.geometry.location,
labelContent: open,
labelClass: "labels", // the CSS class for the label
labelStyle: {
opacity: 0.75
},
labelAnchor: new google.maps.Point(22, 0)
});
});
markers.push(marker);
bounds.extend(place.geometry.location);
}
으로 작동하지만 내가 얻을 오류 :
Uncaught TypeError: Cannot read property 'openNow' of null
것은 내가 해결할 수있는 방법 이 문제?