Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using angular-google-maps and error when instantiate module

I'm using http://angular-google-maps.org/ in my project.

The steps to add to my project are those: http://angular-google-maps.org/use.

When I run my project, browser says:

Uncaught Error: [$injector:modulerr] Failed to instantiate module BeLiga due to:
Error: [$injector:modulerr] Failed to instantiate module BeLiga.ligaControllers due to:
Error: [$injector:modulerr] Failed to instantiate module google-map due to:
Err...<omitted>...1) 

The problem comes when I write:

var moduloMap = angular.module('myController', ['google-maps']);

I've checked everything and can not find the problem.

Ty!

like image 712
JGrancha Avatar asked May 17 '26 14:05

JGrancha


2 Answers

The problem was the load order of scripts:

Example not running:

 <script src="http://maps.googleapis.com/maps/api/js?sensor=false&amp;language=en"></script> 
    <script src="lib/angular/underscore.js"></script>
    <script src="lib/angular/angular-google-maps.min.js"></script>

<script src="lib/angular/angular.js"></script>
    <script src="lib/angular/angular-route.js"></script>
    <script src="lib/angular/angular-sanitize.min.js"></script>
    <script src="lib/angular/angular-animate.js"></script>
    <script src="js/app.js"></script>
    <script src="js/services.js"></script>
 <script src="js/animations.js"></script>

Example running:

    <script src="lib/angular/angular.js"></script>
        <script src="lib/angular/angular-route.js"></script>
        <script src="lib/angular/angular-sanitize.min.js"></script>
        <script src="lib/angular/angular-animate.js"></script>
        <script src="js/app.js"></script>
        <script src="js/services.js"></script>
     <script src="js/animations.js"></script>

 <script src="http://maps.googleapis.com/maps/api/js?sensor=false&amp;language=en"></script> 
        <script src="lib/angular/underscore.js"></script>
        <script src="lib/angular/angular-google-maps.min.js"></script>

As you can see, the problem was the order of the scripts was a silly error but I did not realize and made me lose a lot of time.

If anyone can serve him, I leave the answer.

A greeting and thanks.

like image 106
JGrancha Avatar answered May 20 '26 04:05

JGrancha


I finally got mine fixed by ensuring

    <script src='//maps.googleapis.com/maps/api/js?sensor=false'></script>

Goes above other google scripts. I am using rails so I have it placed above my rails tags:

    <%= stylesheet_link_tag    'application', media: 'all' %>
    <%= javascript_include_tag 'application' %>
    <%= csrf_meta_tags %>

Refer to this post which might give more information. Hope this helps!

like image 30
Dan Avatar answered May 20 '26 03:05

Dan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!