Issue description
Trying to use places service to run a "nearbySearch()"
Steps to reproduce and a minimal demo of the problem
public findHospital() {
let 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]
}
});
}
_What steps should we try in your demo to see the problem?_
Current behavior
Uncaught TypeError: Cannot read property 'nearbySearch' of undefined
Expected/desired behavior
return a list of nearby places
angular2 & angular-google-maps version
latest
Other information
I only ask because the DirectionsService seems to work fine, so i assumed so would the places service
You probably should be using just:
var service = new google.maps.places.PlacesService(document.createElement('div'));
Unless you are using the map anywhere else, but anyway the PlacesService
is not part of this library, so the issue is not related to AGM
Just wanted to reiterate what @jgutix said regarding instantiating the service and that in fact it works fine that way -- I use the textSearch.
right i got it working, just seems it does not work with Observable.bindCallback()