Git Product home page Git Product logo

nativescript-google-places-autocomplete's Introduction

Nativescript Google Places Autocomplete

npm version Twitter Follow

Add location autocomplete to your Nativescript application

Prerequisites

Create and grap your Api key from https://developers.google.com/maps/documentation/javascript/get-api-key?hl=en

Installation

npm install nativescript-google-places-autocomplete

Usage

    import { GooglePlacesAutocomplete } from 'nativescript-google-places-autocomplete';
	
	let API_KEY = "your_api_Key";
	let googlePlacesAutocomplete = new GooglePlacesAutocomplete(API_KEY);

	googlePlacesAutocomplete.search(params)
	      .then((places: any) => {
		      // place predictions list
           }, (error => {
              console.log(error)
          }));
          
	googlePlacesAutocomplete.getPlaceById(place.placeId).then((place) => {
	   .then(function () { });
        }, error => {
            console.log(error)
        })        

Plugin Auther : Aymen Labidi

License

Apache License Version 2.0, January 2004

nativescript-google-places-autocomplete's People

Contributors

dependabot[bot] avatar labidiaymen avatar nathanwalker avatar socha17 avatar tylerablake avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

nativescript-google-places-autocomplete's Issues

Add components to restrict search

Great plugin. Suggestion for adding components to restrict search. Something like below

google-places-autocomplete.common.js

Common.prototype.search = function (terms, components) {
        var requestUrl = google_places_autocomplete_static_1.PLACES_API_URL +
            "?components="+components+"&input=" + encodeURIComponent(terms.trim()) +
            "&types=geocode&key=" +
            this.apikey;
        ...
    };
googlePlacesAutocomplete.search(searchTerm, 'country:IN').then(
	(places) => {
	    	console.log(places);
	}, (error) => {
		 console.log(error);
	}
);

Not working in NS7

I see you've made some changes to support NS7 but my app is crashing on the page where this plugin is used since I migrated to NS7. The error I get is:

System.err: An uncaught Exception occurred on "main" thread.
System.err: Calling js method onCreateView failed
System.err: TypeError: Class constructor Observable cannot be invoked without 'new'
System.err: 
System.err: StackTrace:
System.err: Common(file: node_modules/nativescript-google-places-autocomplete/google-places-autocomplete.common.js:9:0)
System.err: 	at GooglePlacesAutocomplete(file: node_modules/nativescript-google-places-autocomplete/google-places-autocomplete.android.js:7:0)

I haven't changed any code since migration to NS7.

Which platform(s) does your issue occur on?

  • iOS/Android/Both : Android
  • iOS/Android versions : 10
  • emulator or device. What type of device? Samsung Galaxy M21 device

Please, provide the following version numbers that your issue occurs with:

  • CLI: (run tns --version to fetch it) 7.0.11
  • Cross-platform modules: (check the 'version' attribute in the
    node_modules/tns-core-modules/package.json file in your project) 7.0.13
  • Runtime(s): (look for the "tns-android" and "tns-ios" properties in the package.json file of your project) 7.0.1
  • Plugin(s): (look for the version numbers in the package.json file of your
    project and paste your dependencies and devDependencies here)
"dependencies": {
    "@nativescript/core": "^7.0.13",
    "@nativescript/datetimepicker": "^2.0.4",
    "@nativescript/theme": "^3.0.0",
    "@nstudio/nativescript-cardview": "^2.0.1",
    "@nstudio/nativescript-floatingactionbutton": "^3.0.4",
    "@nstudio/nativescript-loading-indicator": "^4.0.0",
    "@nstudio/nativescript-pulltorefresh": "^3.0.1",
    "@proplugins/nativescript-drop-down": "^9.0.2",
    "@triniwiz/nativescript-image-cache-it": "file:plugins/triniwiz-nativescript-image-cache-it-7.0.0.tgz",
    "nativescript": "7.0.11",
    "nativescript-google-places-autocomplete": "^1.0.3",
    "nativescript-material-icons": "^1.0.3",
    "nativescript-toasty": "^3.0.0-alpha.2",
    "nativescript-ui-autocomplete": "^7.0.2"
  },
  "devDependencies": {
    "@nativescript/android": "7.0.1",
    "@nativescript/webpack": "~3.0.0",
    "sass": "1.27.0"
  },

Please document what changes would be required in order for the plugin to work with NS7. I've glanced at your demo but couldn't figure it out.

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.