The bindMapEvents()-function attaches events to google-maps objects, but it does not handle unbinding when objects are removed (or replaced).
The following use case will cause a memory leak each time setProject() is called.
var markers = {
"firtProject": [/* list of Google Maps markers */],
"secondProject": [/* list of Google Maps markers */]
};
$scope.setProject = function(project) {
$scope.markers = markers[project];
};
$scope.markerClicked = function(marker) {
/* some action */
};
The
bindMapEvents()
-function attaches events to google-maps objects, but it does not handle unbinding when objects are removed (or replaced).The following use case will cause a memory leak each time
setProject()
is called.Directive should store unbind markers when they are removed from scope.