首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google放置JS weekday_text

Google放置JS weekday_text
EN

Stack Overflow用户
提问于 2016-10-14 10:32:50
回答 1查看 837关注 0票数 0

有人知道为什么我的"nearbySearch“谷歌搜索会丢失数据吗?

当我使用places进行附近的搜索时,每个weekday_text数组都返回为空,但是当我对初始搜索中的某个位置执行"getDetails“请求时,weekday_text将被返回。

http://codepen.io/anon/pen/RGBVJR

代码语言:javascript
复制
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();
代码语言:javascript
复制
<div id="map">
</div>
<script src="https://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>

请查看console.logs以查看数据差异。

知道为什么会这样吗?我宁愿不必执行第二个API请求来检索工作日请求。

谢谢,

汤姆

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-10-14 11:03:34

nearbySearch返回一个PlaceResult对象数组。

正如您可以看到的,这里,PlaceResult没有weekday_text属性。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40041032

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档