问题描述
尝试使用地点服务运行“nearbySearch()”
重现问题的步骤和问题的最小演示
公共查找医院(){
让 map = new google.maps.Map(document.createElement('div'));
var placesService = new google.maps.places.PlacesService(map);
var place: any = Observable.bindCallback(placesService.nearbySearch);
var pyrmont = new google.maps.LatLng(19.107567, 72.8335)
var request = {
location: pyrmont,
radius: 200,
types: ['hospital', 'health'] // this is where you set the map to get the hospitals and health related places
};
return place(request)
.map((response) => {
let result: IDistanceResult;
console.log(response);
return result = {
directions: response[0],
status: response[1]
}
});
}
_我们应该在您的演示中尝试哪些步骤来查看问题?_
当前行为
未捕获的类型错误:无法读取未定义的属性“nearbySearch”
预期/期望的行为
返回附近地点的列表
angular2 & angular-google-maps 版本
最新的
其他信息
我只问是因为 DirectionsService 似乎工作正常,所以我认为地点服务也会如此
您可能应该只使用:
var service = new google.maps.places.PlacesService(document.createElement('div'));
除非您在其他任何地方使用地图,但无论如何PlacesService
不是此库的一部分,因此问题与 AGM 无关
只是想重申@jgutix关于实例化服务的说法,事实上它以这种方式工作得很好——我使用textSearch 。
对,我让它工作了,只是似乎它不适用于 Observable.bindCallback()