Symeon Mattes
Symeon Mattes

Reputation: 1268

Getting coordinates from google maps place autocomplete

I would like to use the google place autocomplete in an ionic2 project. I have found this npm package

https://www.npmjs.com/package/ionic2-google-places-autocomplete

which works as it describes. However in the callback=detail($event[0]) I don't get the coordinates of the selected address. What I get is a javascript object that has information about the address I have typed in.

Is there any way to have a google place autocomplete in an ionic2 project that gives me the coordinates of the selected address.

Thanks in advance

Upvotes: 0

Views: 653

Answers (1)

Symeon Mattes
Symeon Mattes

Reputation: 1268

The callback that the npm package has is the same described in https://developers.google.com/places/web-service/autocomplete. This doesn't return the location but it returns the place_id.

​With the place_id you can call the place details (https://developers.google.com/places/web-service/details) to obtain the lat and lon.

Upvotes: 1

Related Questions