簡體   English   中英

Google Places JS API weekday_text

[英]Google Places JS API weekday_text

有誰知道為什么我的“ nearbySearch” Google地方搜索缺少數據?

當我使用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請求來檢索工作日請求。

謝謝,

湯姆

附近的搜索返回PlaceResult對象的數組。

正如你可以看到這里 ,組PlaceResult沒有weekday_text財產。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM