tombatossals/angular-leaflet-directive — pull request #88 by grantlucas (2013-08-08 03:54:28+00:00)
Title: Changed marker events from callbacks to rootScope broadcasts

**Problem Found**

Alright. My initial tests and work that went into #86 seemed like they would have done the trick for marker events. Once I got down to *actually* using marker events this evening, I found that they "worked" but with a major issue.

The issue is that Angular's `$digest` process was getting messed with. If you changed any values on `$scope` within the callback, the proper listeners wouldn't get triggered. If you called `$scope.$digest()` within the callback on the event, all worked as expected. Clearly this is more of a bug.

**Solution**

I've updated the marker events to use `$broadcast` to the root scope. All Leaflet marker events are automatically set up on each marker. When you set up a listener for these events you use

$scope.$on('leafletDirectiveMarker.', function(e, data){
/* e is the Angular event data */
/* data is the information passed from the marker. data.markerName is the name of the marker acted upon */
});

**Note:** If you've started using the marker events from #86, you'll need to update to use the proper event listeners as that code was removed.