angular-google-maps icon indicating copy to clipboard operation
angular-google-maps copied to clipboard

Does AGM have PlacesService? I cant seem to get it to work.

Open ChrisDevinePimss opened this issue 8 years ago • 3 comments

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

ChrisDevinePimss avatar Feb 23 '18 12:02 ChrisDevinePimss

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

jgutix avatar Feb 25 '18 04:02 jgutix

Just wanted to reiterate what @jgutix said regarding instantiating the service and that in fact it works fine that way -- I use the textSearch.

jgeiger-cr avatar Feb 25 '18 16:02 jgeiger-cr

right i got it working, just seems it does not work with Observable.bindCallback()

ChrisDevinePimss avatar Feb 26 '18 07:02 ChrisDevinePimss