Google 放置 JS API weekday_text
Google Places JS API weekday_text
有谁知道为什么我的 "nearbySearch" google 地点搜索缺少数据?
当我使用地点 API 进行附近搜索时,每个 weekday_text 数组 returns 都是空的,但是当我对其中一个位置发出 "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 请求来检索工作日请求。
谢谢,
汤姆
nearbySearch returns PlaceResult 对象数组。
如您所见here,PlaceResult 没有weekday_text 属性.
有谁知道为什么我的 "nearbySearch" google 地点搜索缺少数据?
当我使用地点 API 进行附近搜索时,每个 weekday_text 数组 returns 都是空的,但是当我对其中一个位置发出 "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 请求来检索工作日请求。
谢谢,
汤姆
nearbySearch returns PlaceResult 对象数组。
如您所见here,PlaceResult 没有weekday_text 属性.