【发布时间】:2020-08-15 22:46:04
【问题描述】:
您好,我正在使用google map api和google places api,并且我大量遇到这个问题。事实上,每次调用 google places api:
“open_now 自 2019 年 11 月起已弃用,将于 2020 年 11 月关闭。使用 PlacesService.getDetails() 中的 isOpen() 函数”
我阅读了文档并进行了一些研究,但被告知我不应该使用 open_now。
我的项目中没有使用 open_now 或 isOpen()
谁来解决这个问题?
const map = store.state.map;
const google = store.state.google;
const service = new google.maps.places.PlacesService(map);
const center = map.getCenter();
const nearbySearchRequest = {
location: center,
radius: 650,
types: ["restaurant"]
};
function nearbySearchCallback(results, status) {
const API_KEY = firebaseConfig.apiKey;
if (status == 'OK') {
let restaurants = results;
restaurants.forEach((restaurant, i) => {
// For each restaurant, we get the reviews
function getDetailsCallback(reviews) {
restaurant.reviews = reviews;
}
const getDetailsRequest = {
fields: ["reviews"],
placeId: restaurant.place_id
};
service.getDetails(getDetailsRequest, getDetailsCallback);
//For each restaurant, we get the image
const lat = restaurant.geometry.location.lat();
const lng = restaurant.geometry.location.lng();
restaurant.img = `https://maps.googleapis.com/maps/api/streetview?size=150x150&location=${lat},${lng}&key=${API_KEY}`;
});
store.commit("UPDATE_RESTAU", restaurants);
setMarkers();
}
}
service.nearbySearch(nearbySearchRequest, nearbySearchCallback);
【问题讨论】:
-
不会在example in the documentatoni 中发生(fiddle 使用该代码)。你能提供一个minimal reproducible example 使用你的代码来证明你的问题吗?
-
我可以在这里重现这个问题:jsfiddle.net/thgjxcwq;这似乎是一种预期行为,因为Nearby Search 返回所有可用数据字段,包括opening_hours。如果您没有明确使用 opening_hours 数据字段,我建议您在 Google Maps Public Issue Tracker 上提出问题以消除错误。
标签: google-maps google-places-api