This is a cross-platform (iOS & Android) Nativescript plugin for the Google Places Picker
OTHER License
This is a cross-platform (iOS & Android) Nativescript plugin for the Google Places Picker
iOS - Cocoapods is installed
Android - Latest Google Play services SDK installed
Google Places API Key - Go to the Google Developers Console, create a project, and enable the Google Places API for Android
and Google Places API for iOS
APIs. Then under credentials, create an API key.
Google Maps API Key - Go to the Google Developers Console, create a project, and enable the Google Maps Android API
and Google Maps SDK for iOS
APIs. Then under credentials, create an API key.
tns plugin add nativescript-google-place-picker
Add API key to app manifest(AndroidManifest.xml
). Refer to Android/add key
The plugin will default to latest available version of the Android play-services-places
SDK. If you need to change the version, you can add a project ext property googlePlayServicesVersion
like so:
// /app/App_Resources/Android/app.gradle
project.ext {
googlePlayServicesVersion = "+"
}
In the main script of your app app.js
, use the following to add the API key (providing your key in place of PUT_API_KEY_HERE
)
if(application.ios) {
PlacePicker.iosProvideAPIKey("PUT_API_KEY_HERE");
}
If you are using Angular, you need to modify the app.module.ts
as follows:
import * as platform from "platform";
import {PlacePicker} from "nativescript-google-place-picker"
....
if (platform.isIOS) {
PlacePicker.iosProvideAPIKey("PUT_API_KEY_HERE");
}
...
public onShowPicker() {
var picker = new PlacePicker()
picker.present()
.then((r)=>{
console.log(r.latitude)
console.log(r.longitude)
})
.catch((e)=>{
console.log("Error: "+e);
})
}
...