angular-mapbox
angular-mapbox copied to clipboard
Multiple mapbox instances and markers
Hi,
I'm working with multiple mapbox instances on the same page, and it does not properly handle adding markers with ng-repeat. Looking at the angular-mapbox.js, it seems that this is still a work in progress;
// TODO: tie markers to specific map instance
I would like to be able to solve this, but I'm new to angular and can't quite figure it out. The addMarker function on line 444 receives a map instance it will add the markers to. This map is passed after getting it through the controller.getMap()
call. However, I dont understand the implementation of getMap() or where to modify it. Could you point me in the right direction?
PS: for anyone looking for a nasty hacky workaround; I've added a mapinstance=x
to the marker
element, and in the marker directive I've placed a condition to check this value in attrs.mapinstance
, and depending on the passed value I'm setting map = mapboxService.getMapInstances()[x]
(line 420). Although this works, it may not be the right solution, as I'm simply overwriting the passed map argument. (I have no idea of the side effects, though I haven't experienced any bugs so far)
Thanks for the great work!
Hi, I have the same issue and my markers aren't updating well. So what I do is that I generate a static map and a dynamic map instead of two dynamics...