Naimikan / angular-mapboxgl-directive

AngularJS directive for Mapbox GL
https://naimikan.github.io/angular-mapboxgl-directive/
MIT License
49 stars 21 forks source link

Issue with multiple maps #14

Closed mm-ns closed 7 years ago

mm-ns commented 7 years ago

Hi again,

I have an issue where I load multiple independent maps in the same page, and I am having some issues that I can't really pinpoint with both layers and sources.

I was able to replicate a plunkr here: https://plnkr.co/edit/HY2tR5MSliZKU9Q3fLB6?p=preview

Do you have any idea of why that is?

I basically make independent maps in an array and each of the map has its own params, layers, controls and sources. Also I have them in an ng-if so it doesn't try to render the DOM before everything is assigned and has a value..

Would love to have your take on it! Thanks!!

Naimikan commented 7 years ago

Hi @mm-ns!

I think I know what is the problem. I did all the management factories as Singleton and I have to do as a providers. I'm on it.

Sorry!

mm-ns commented 7 years ago

Hi @Naimikan !

No worries! I already appreciate the work you do! Thx! So what's the underlaying reason why this creates issues? Cause I just now tried to be "smarter" and create only one global control, layers, and then in the ngrepeat, use the global layers and controls and simply change the center of the map in order to focus on different areas of a city. but that prompted a similar issue where the first map rendered, has all the markers in it, and then the subsequent maps in the loop fail (they are displayed, but show nothing).

Naimikan commented 7 years ago

Hi @mm-ns!

I updated a new version solving your issue! https://plnkr.co/edit/BDaAZBis2bqP1gzneksv?p=preview

Tell me if it worked!

mm-ns commented 7 years ago

Hey @Naimikan.

thanks a ton, it worked!