0

Hello I try to load the google maps api asynchronously in AngularJS following this link:http://angular-ui.github.io/angular-google-maps/#!/

I get the following error:

Error: [$injector:modulerr] Failed to instantiate module due to:
[$injector:modulerr] Failed to instantiate module RegisterClientModule  due to:
undefined is not an object (evaluating 'uiGmapGoogleMapApiProvider.configure')

my code(Please note: I just started with AngularJS 2-3 days ago, I guess my mistake is easy to fix once I fully understand why this is not working):

var module = angular.module('RegisterClientModule', [])
.config(['$routeProvider', function    config($routeProvider,uiGmapGoogleMapApiProvider) {
$routeProvider.when('/registerclient', {
    controller: 'RegisterClientController',
    templateUrl: '/scripts/modules/RegisterClientModule/registerClientView.html'
});
uiGmapGoogleMapApiProvider.configure({
    v: '3.17',
    libraries: 'weather,geometry,visualization'
});
}]);

module.controller('RegisterClientController', ['$scope', function($scope, uiGmapGoogleMapApi ) {
uiGmapGoogleMapApi.then(function(maps) {
    console.log("Google maps api loaded");
});
$scope.map = { center: { latitude: 45, longitude: -73 }, zoom: 8 };
console.log("Google maps api provider:"+uiGmapGoogleMapApi );

}]);

Thanks for your help

1 Answer 1

0

You missed to include uiGmapgoogle-maps in you app module. That will make available the uiGmapGoogleMapApiProvider & all other API of Google map.

var module = angular.module('RegisterClientModule', ['uiGmapgoogle-maps'])
Sign up to request clarification or add additional context in comments.

2 Comments

I have added it, actually when I don't try to load it async the module works just fine, the problem only occurs when I try to configure the module to load async.
ever find your answer? Having the same problem and i added the uiGmapgoogle-maps module

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.