Code Monkey home page Code Monkey logo

angularjs-google-places's Introduction

AngularJS-Google-Places

An angular.js wrapper around the Google Places API

Bower

This module is available as bower package, install it with this command:

bower install angularjs-google-places

or

bower install git://github.com/arunisrael/angularjs-google-places.git

Demo

See this plunker

Usage

  • Include the Google Maps JS library in your app
  • Add ngGPlaces as a dependency
  • Inject ngGPlacesAPI as a dependency to your controller or other service
  • Invoke the nearbySearch method and pass in a latitude/longitude
  • Invoke the placeDetails method and pass in a Google Places reference id

Example

var myApp = angular.module('myApp',['ngGPlaces']);

// optional if you want to modify defaults
myApp.config(function(ngGPlacesAPIProvider){
  ngGPlacesAPIProvider.setDefaults({
    radius:500
  });
});

myApp.controller('mainCtrl',function($scope,ngGPlacesAPI){
  $scope.details = ngGPlacesAPI.placeDetails({reference:"really_long_reference_id"}).then(
    function (data) {
      return data;
    });

  $scope.data = ngGPlacesAPI.nearbySearch({latitude:-33.8665433, longitude:151.1956316}).then(
    function(data){
      return data;
    });
});

Further Customizations

You can override any default option below via setDefaults on the ngGPlacesAPIProvider Or by passing that property to the nearbySearch or placeDetails method

var defaults = {
    radius: 1000,
    sensor: false,
    latitude: null,
    longitude: null,
    types: ['food'],
    map: null,
    elem: null,
    nearbySearchKeys: ['name', 'reference', 'vicinity'],
    placeDetailsKeys: ['formatted_address', 'formatted_phone_number',
        'reference', 'website'
    ],
    nearbySearchErr: 'Unable to find nearby places',
    placeDetailsErr: 'Unable to find place details',
};

Testing

grunt test

License

MIT

angularjs-google-places's People

Contributors

arunisrael avatar lautarobock avatar

Watchers

 avatar  avatar

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.