0.4.0 • Published 7 years ago

angular-gmaps-initializer v0.4.0

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

angular-gmaps-initializer

An Angular module to initialize google maps.

NPM version License Downloads

It injects an Angular Factory to initialize Google Maps API.

Table of contents:

Get Sarted

(1) You can install angular-communicator using 3 different ways: Git: clone & build this repository Bower:

$ bower install angular-gmaps-initializer --save

npm:

$ npm install angular-gmaps-initializer

(2) Include angular-gmaps-initializer.js (or angular-gmaps-initializer.min.js) from the dist directory in your index.html, after including Angular itself.

(3) Add 'AngularGmapsInitializer' to your main module's list of dependencies.

When you're done, your setup should look similar to the following:

<!doctype html>
<html ng-app="myApp">
<head>

</head>
<body>
    ...
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>
    <script src="bower_components/js/angular-gmaps-initializer.min.js"></script>
    ...
    <script>
        var myApp = angular.module('myApp', ['AngularGmapsInitializer']);

    </script>
    ...
</body>
</html>

Usage

You specify additional parameter to load within the bootstrap request by specifying an object and passing it to initialize. The initialize returns a promise for the map initialization.

myApp.controller('MainCtrl', function($scope, angularGmapsInitializer) {
  var options = {
    libraries: 'visualization, places',
    language: 'en',
    key: 'YOUR_API_KEY'
  };
  
  angularGmapsInitializer.initialize(options).then(function() {
        //your sucess code
      }, function(err) {
        //your error code
      });
});

This will create a url like https://maps.googleapis.com/maps/api/js?v=3&libraries=visualization, places&language=en&key=YOUR_API_KEY

0.4.0

7 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago