angular-mapboxgl-directive
angular-mapboxgl-directive copied to clipboard
Map events are not $broadcast inside an $apply
Currently, if I hook into map events using $scope.$on('mapboxglMap:...'
the handler is running outside of a digest cycle and so model changes inside of them will not be reflected through the rest of the app.
According to the Angular dev guide, $scope.$apply() should occur as close to the async event binding as possible.
Is there a reason not to do $rootScope.$apply($rootScope.$broadcast('mapboxglMap:' ...))
inside mapboxglEventsUtils.exposeMapEvents
or in glControl
when adding angular events for the control?
This is relevant particularly when listening to mapboxglDraw events.
Hi @ezk84!
Events was the first things that I did in the directive. Thank you for the advice! I will update a new version with that enhancement.
Thank you!
The only problem may be with the mouse events, where each mouse move would trigger a digest cycle through $rootScope.apply
, may be too much no?
Also i need to control and get access to data in controllers. can it be done with about mapInstance