I am considering migrating from backbonejs to angularjs.
In backbone I am able to initialize a view at which point I create an instance of google map. I can then pa
Here's my solution for using the maps api with Angularjs routeProvider: in your index you have to add:
angular-google-maps.min.js and lodash.min.js
in application.js:
(function() {
var app = angular.module("myApp", ["ngRoute", "uiGmapgoogle-maps"]);
app.config(function(uiGmapGoogleMapApiProvider) {
uiGmapGoogleMapApiProvider.configure({
key: 'YOUR KEY HERE',
v: '3.17',
libraries: 'weather,geometry,visualization'
});
});
app.config(function($routeProvider) {
$routeProvider
.when("/home", {
templateUrl: "home.html",
controller: "HomeController"
})
.when("/workwith", {
templateUrl: "workwith.html",
controller: "WorkwithController"
})
.otherwise({
redirectTo: "/home"
});
});
})();
Last But not least in your controller:
(function() {
var app = angular.module("myApp");
var MyController = function($scope, $http, $log, $location, $routeParams, uiGmapGoogleMapApi) {
$log.info("MyController");
$log.info($routeParams);
// Define variables for our Map object
var areaLat = 44.2126995,
areaLng = -100.2471641,
areaZoom = 3;
uiGmapGoogleMapApi.then(function(maps) {
$scope.map = {
center: {
latitude: areaLat,
longitude: areaLng
},
zoom: areaZoom
};
$scope.options = {
scrollwheel: false
};
});
};
app.controller("MyController", MyController);
})();