0
有谁知道为什么我的“nearbySearch”google地方搜索缺少数据?Google Places JS API weekday_text
当我使用places API进行附近搜索时,每个weekday_text数组返回为空,但是当我在初始搜索中对其中一个位置执行“getDetails”请求时,会返回weekday_text。
http://codepen.io/anon/pen/RGBVJR
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>
请参阅console.logs看到的数据差异。
任何想法为什么这样?我宁愿不必做第二次API请求来检索星期几请求。
谢谢,
汤姆
不幸的是,该文档还指出,详细信息请求返回相同类型的对象。我会说文档已过时。 – geocodezip
它开始看起来像我需要做很多API调用。有没有人找到一个有效的方法来做到这一点? – Thomas