Giter Site home page Giter Site logo

skynet2 / ngx-google-places-autocomplete Goto Github PK

View Code? Open in Web Editor NEW
92.0 4.0 75.0 4.06 MB

Google Places autocomplete for angular web project

License: MIT License

TypeScript 75.42% HTML 4.46% JavaScript 20.13%
angular google-places google-place-api typescript places-autocomplete ngx

ngx-google-places-autocomplete's Introduction

ngx-google-places-autocomplete

This module is a wrapper for Google Places Autocomplete js library.

NPM

Installation

npm

npm install ngx-google-places-autocomplete

yarn

yarn add ngx-google-places-autocomplete

Integration

  1. Add google library in your index.html file :
    <script src="https://maps.googleapis.com/maps/api/js?key=<Your API KEY>&libraries=places&language=en"></script>
  1. Replace with google places api key. Ref - https://developers.google.com/places/web-service/get-api-key

Usage

  1. Add a module into your application (as a rule app.module.ts)
import { GooglePlaceModule } from "ngx-google-places-autocomplete";

@NgModule({
    imports: [GooglePlaceModule, BrowserModule, FormsModule, ...],
        ....
        })
  1. Add directive ngx-google-places-autocomplete to your input field (options is an optional parammeter)
<input ngx-google-places-autocomplete [options]='options' #placesRef="ngx-places" (onAddressChange)="handleAddressChange($event)"/>
  1. Additionally you can reference directive in your component
    @ViewChild("placesRef") placesRef : GooglePlaceDirective;
    
        public handleAddressChange(address: Address) {
        // Do some stuff
    }

Angular Universal

In order to use under angular universal please check that comment #15 (comment)

Options

Refer to original google maps api - https://developers.google.com/maps/documentation/javascript/places-autocomplete Options object - https://github.com/skynet2/ngx-google-places-autocomplete/blob/master/src/objects/options/options.ts Google doc for Options : https://developers.google.com/maps/documentation/javascript/reference/places-widget#AutocompleteOptions Example :

[options]="{
    types: [],
    componentRestrictions: { country: 'UA' }
    }"

GitHub

Please feel free to declare issues or contribute: https://github.com/skynet2/ngx-google-places-autocomplete

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.