…pes before calling their respective functions on directive events.
When browsing away from a page using the angular-mapboxgl-directive before the map has had enough time to fully load, errors were being thrown within the $destroy event handlers for the markers, layers, and sources directives. This occurs when the respective manager class (MarkersManager, LayersManager, or SourcesManager) for one or more of these directives (whichever of them have been implemented) hasn't yet been defined on its respective scope, something that only happens once the underlying mapboxgl.Map has fully loaded and controller._mapboxGlMap is resolved in the main directive's controller. To prevent these errors, I've simply added checks to each of these directive's $destroy evens to ensure the manager has been defined on its scope before making the necessary function calls on it.
…pes before calling their respective functions on directive events.
When browsing away from a page using the angular-mapboxgl-directive before the map has had enough time to fully load, errors were being thrown within the $destroy event handlers for the markers, layers, and sources directives. This occurs when the respective manager class (MarkersManager, LayersManager, or SourcesManager) for one or more of these directives (whichever of them have been implemented) hasn't yet been defined on its respective scope, something that only happens once the underlying mapboxgl.Map has fully loaded and controller._mapboxGlMap is resolved in the main directive's controller. To prevent these errors, I've simply added checks to each of these directive's $destroy evens to ensure the manager has been defined on its scope before making the necessary function calls on it.