0

I've noticed a very strange bug (or maybe I did something wrong) between ngAnimate and ngRoute. If I try to reload the current route without reloading the full page, something goes wrong and I can't reinitialize my leaflet map. I've created a plunker to demonstrate this behaviour.

If I/you don't load the ngAnimate module everything goes as planned. Am I doing something wrong or is it bug/feature?

Cheers, Daniel

Daniel Gerber
  • 3,226
  • 3
  • 25
  • 32

1 Answers1

0

It seems that leaflet initializes Map container despite the fact it is already initialized (taken from the console):

Error: Map container is already initialized.
at o.Map.o.Class.extend._initContainer (http://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js:6:25685)
at o.Map.o.Class.extend.initialize (http://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js:6:19036)
at new o.Class.extend.e (http://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js:6:2539)
at Object.o.map (http://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js:6:31439)
at new <anonymous> (http://run.plnkr.co/XI7Vl2hTc4EgnNEf/script.js:27:24)
at invoke (https://code.angularjs.org/1.3.0/angular.js:4152:17)
at Object.instantiate (https://code.angularjs.org/1.3.0/angular.js:4163:23)
at https://code.angularjs.org/1.3.0/angular.js:8350:28
at link (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular-route.js:910:26)
at invokeLinkFn (https://code.angularjs.org/1.3.0/angular.js:8111:9) <div ng-view="" class="ng-scope"> 

And this leads angularjs to halt. Try this solution: refresh leaflet map: map container is alreay initialized

I think that in your case it would be the best to remove container and then add it again :)

Community
  • 1
  • 1
SzybkiSasza
  • 1,591
  • 12
  • 27