我的目标是使用“routeRequest”请求一组符合我的标准的位置并保存它们。为此,我使用谷歌地点来检查地图中心周围的位置。
let map = new google.maps.Map(document.querySelector("#myMap"), {
center: { lat: 41.148481, lng: -8.606893 },
zoom: 15
});
let service = new google.maps.places.PlacesService(map);
service.nearbySearch(routeRequest, callback);
let routeRequest = {
location: map.center,
radius: '1000',
type: [this.typeRoute]
};
function callback(results, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
for (const result of results) {
this.listLocations.push(result);
}
}
}
Run Code Online (Sandbox Code Playgroud)
问题是,placesService 似乎无法识别地图