Skip to content
This is a cross-platform (iOS & Android) Nativescript plugin for the Google Places Picker
TypeScript JavaScript Ruby
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
platforms
scripts
typings/ios
.gitignore
.npmignore
LICENSE
README.md
index.d.ts
package.json
place-picker.android.d.ts
place-picker.android.ts
place-picker.ios.d.ts
place-picker.ios.ts
references.d.ts
tsconfig.json

README.md

NativeScript plugin for Google Place Picker

This is a cross-platform (iOS & Android) Nativescript plugin for the Google Places Picker

Prerequisites

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.

Installation

Install the plugin using the NativeScript CLI tooling

tns plugin add nativescript-google-place-picker

Setup Google Maps API

Setup Android API Key

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 = "+"
}

Setup iOS API Key

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");
}

Usage Example

...
public onShowPicker() {
  var picker = new PlacePicker()

  picker.present()
      .then((r)=>{
          console.log(r.latitude)
          console.log(r.longitude)
      })
      .catch((e)=>{
          console.log("Error: "+e);
      })
}
...
You can’t perform that action at this time.