lukemadera:autoform-googleplace 1.0.7

Google Places Autocomplete input (without map). Returns an object with formatted address components

Platform: Meteor

Language: JavaScript

Repository: https://github.com/lukemadera/meteor-autoform-googleplace

View on registry: https://atmospherejs.com/lukemadera/autoform-googleplace

Install: meteor add lukemadera:autoform-googleplace@=1.0.7


lukemadera:autoform-googleplace

An add-on Meteor package for aldeed:autoform. Provides a single custom input type, "googleplace", which renders an input that is given Google Places Autocomplete functionality (but without any map; just a pure input box) and that returns an object with fullAddress, lat, lng, street, city, state, zip, country. https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete

This DOES work when wrapped in Phonegap / Cordova AND with iOS8 and 3rd party keyboards (which the default GoogleUI places autocomplete does NOT)! More info:

Demo

Demo

Source

Dependencies

  • aldeed:autoform
  • Google Maps Places script (put in your entry HTML file)
    • <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=places"></script>

Installation

In a Meteor app directory:

meteor add lukemadera:autoform-googleplace

Usage

Specify "googleplace" for the type attribute of any input and set the SimpleSchema to be an object:

{{> afQuickField name="address" type="googleplace" opts=optsGoogleplace}}

In the schema, which will then work with a quickForm or afQuickFields:

AddressSchema =new SimpleSchema({
  fullAddress: {
    type: String
  },
  lat: {
    type: Number,
    decimal: true
  },
  lng: {
    type: Number,
    decimal: true
  },
  geometry: {
    type: Object,
    blackbox: true
  },
  placeId: {
    type: String
  },
  street: {
    type: String,
    max: 100
  },
  city: {
    type: String,
    max: 50
  },
  state: {
    type: String,
    regEx: /^A[LKSZRAEP]|C[AOT]|D[EC]|F[LM]|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEHINOPST]|N[CDEHJMVY]|O[HKR]|P[ARW]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY]$/
  },
  zip: {
    type: String,
    regEx: /^[0-9]{5}$/
  },
  country: {
    type: String
  }
});

PropertySchema =new SimpleSchema({
  address: {
    type: AddressSchema,
    optional: true
  }
});

Template.autoformGoogleplaceBasic.helpers({
  optsGoogleplace: function() {
    return {
      // type: 'googleUI',
      // stopTimeoutOnKeyup: false,
      // googleOptions: {
      //   componentRestrictions: { country:'us' }
      // }
    }
  }
});

Options

See the documentation at the top of the javascript file for options you can pass in to customize.

Releases

  • 1.0.7 - October 16, 2015 15:48
  • 1.0.6 - August 02, 2015 16:09
  • 1.0.0 - February 25, 2015 18:25

Project Statistics

SourceRank 8
Dependent repositories 0
Total releases 3
Latest release
First release
Stars 24
Forks 21
Watchers 1
Contributors 3
Repo Size: 226 KB

Top Contributors See all

Luke Madera Lukas Strassel Mathieu Gallas Parent

Something wrong with this page? Make a suggestion

Export .ABOUT file for this library

Last synced: 2016-12-21 08:13:00 UTC

Login to resync this project