An Angular module to initialize google maps.
It injects an Angular Factory to initialize Google Maps API.
(1) You can install angular-communicator using 3 different ways:
Git:
clone & build this repository
Bower:
$ bower install angular-gmaps-initializer --savenpm:
$ 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>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