2

I am trying to get angularjs-google-maps show a map in an angularjs project with the following code. (Only relevant code sections shown.)

In index.html:

<script src="http://rawgit.com/allenhwkim/angularjs-google-maps/master/build/scripts/ng-map.min.js"></script>

In app.js:

var forecastApp = angular.module('forecastApp', ['ngRoute', 'ngResource', 'ngSanitize','angularjs-dropdown-multiselect','ngMap']);

...

.when('/map',
                {
                    controller:'mapController',
                    templateUrl:'app/map/_map.html'
                })

In _map.html:

<div map-lazy-load="http://maps.google.com/maps/api/js">
  <map center="current-location" zoom="8">
    <info-window position="current-location" visible="true">
      <span>Loation found using HTML5.</span>
    </info-window>
  </map>
</div>

mapController in mapController.js is instantiated and empty.

In Firefox I am getting some infinite loop with hundreds of navbars on top of each other until it crashes, in Chrome I am getting timeout without anything shown (just a Waiting for rawgit.com) and managed to get a "stack size exceeded" error once, indicating a circular reference possibly? The lazy instantiation of google maps is not an issue, the "Waiting for ..." shows the last domain visited for downloading js/css code, so the server is not down (tried including a locally stored ng-map.min.js too).

Thank you.

Tiha
  • 598
  • 6
  • 10

1 Answers1

1

Sorry for blaming angularjs-google-maps module for my issue. It was the routing in angularjs. This code section below in app.js caused the problem:

forecastApp.config(function($routeProvider) {
    $routeProvider
        .when('/',
            {
                controller:'',
                templateUrl:''
            })
        .when('/location',
            {
                controller:'locationController',
                templateUrl:'app/location/_location.html'
            })
        .otherwise({redirectTo:'/'});
});

The when('/') without a controller and a template and otherwise({redirectTo:'/'}) made angular get into some weird loop. After deleting the when('/') section or adding a controller and template to it, everything works fine.

Tiha
  • 598
  • 6
  • 10