0
내 "nearbySearch"Google 장소 검색에서 데이터가 누락 된 이유를 아는 사람이 있습니까?Google Places JS API weekday_text
장소 API를 사용하여 주변 검색을 수행 할 때마다 모든 weekday_text 배열이 빈 상태로 반환되지만 초기 검색에서 위치 중 하나에 "getDetails"요청을하면 weekday_text가 반환됩니다.
데이터 불일치를 확인하기 위해 console.logs를 참조하십시오
var map;
var service;
// Nearby search
var showPosition = function() {
var geolocation = new google.maps.LatLng(51.5074, -0.1278);
map = new google.maps.Map(document.getElementById('map'), {
center: geolocation,
zoom: 15
});
var request = {
location: geolocation,
radius: '500',
types: ['bar']
};
service = new google.maps.places.PlacesService(map);
service.nearbySearch(request, callback);
};
showPosition();
function callback(results, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
console.log(results);
}
}
// Direct location check
function altTest() {
var map = new google.maps.Map(document.getElementById('map'), {
center: new google.maps.LatLng(51.5074, -0.1278),
zoom: 15
});
var service = new google.maps.places.PlacesService(map);
service.getDetails({
placeId: 'ChIJ78fbAc8EdkgRWG1dhffz9AY'
}, function (place, status) {
if (status === google.maps.places.PlacesServiceStatus.OK) {
console.log(place.opening_hours.weekday_text);
}
});
}
altTest();
<div id="map">
</div>
<script src="https://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>
http://codepen.io/anon/pen/RGBVJR
.왜 그런지 알고 싶습니다. 평일 요청을 검색하기 위해 두 번째 API 요청을하지 않아도됩니다.
감사합니다, PlaceResult 객체의 배열을 반환 nearbySearch
톰
불행히도 설명서에는 세부 요청이 동일한 유형의 개체를 반환한다고 나와 있습니다. 나는 문서가 오래되었다고 말할 것이다. – geocodezip
많은 API 호출을해야 할 것처럼 보입니다. 누구든지 효율적인 방법을 찾았습니까? – Thomas