Code Monkey home page Code Monkey logo

nativescript-google-place-picker's Introduction

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

nativescript-google-place-picker's People

Contributors

dacrystal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

shiv19

nativescript-google-place-picker's Issues

Great plugin

Great plugin would extending it for places auto-complete be something you're interested in? I could help work towards it as well.

Error is: Failed to build plugin nativescript-google-place-picker

Unable to apply changes on device: emulator-5554. Error is: Failed to build plugin nativescript-google-place-picker :
Error: Command ./gradlew failed with exit code 1 Error output:

FAILURE: Build failed with an exception.

  • Where:
    Build file '/Users/user/Desktop/sourcecode/srs/client/platforms/tempPlugin/nativescript_google_place_picker/build.gradle' line: 60

  • What went wrong:
    Could not compile build file '/Users/user/Desktop/sourcecode/srs/client/platforms/tempPlugin/nativescript_google_place_picker/build.gradle'.

startup failed:
build file

google place picker not working in IOS infinite search screens on search icon click

Hi @dacrystal

I was successfully get the google place in android, but ios i am not getting google place search option .......
and also i am getting android address not properly....please see the sample output below
"JS: {"nativePlace":{},"id":"ChIJ0ZqH66_6NToRQPIp3npxdP4","name":"Pizza Hut","address":"39 & 1","latitude":16.5025591,"longitude":80.64261139999999}
JS: 16.5025591
JS: 80.64261139999999
JS: 39 & 1 // see this is address i am getting in android*** /////////
JS: Pizza Hut
JS: Camera changed: {"latitude":-33.85999989127037,"longitude":151.1999999731779,"zoom":8,"bearing":0,"tilt":0} false "

// ios search image attached below see for reference /////
image

In android not working properly

I am trying to implement google Places APIs (Places Autocomplete) by using your plugin. My app is successfully run, with a button click but unable to search a place.
and i am getting an error "placesautocomplete result code = 2"........

GMSPlacePicker being deprecated by Google

Hi,
I just noticed this warning on Google's Place Picker documentation:

Notice: The implementation of the place picker has changed. As of version 2.3 of the Google Places API for iOS, the GMSPlacePicker class is deprecated, replaced by GMSPlacePickerViewController. Use of the GMSPlacePicker class will only be supported until May 1, 2018. We recommend that you update your code to use GMSPlacePickerViewController when possible.

Is there a plan to update the plugin to use the newer, supported class?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.