tombatossals/angular-leaflet-directive — pull request #86 by grantlucas (2013-08-04 04:14:08+00:00)
Title: Support for marker events

As mentioned in #74, I am in need of marker events. I’ve added marker events in the same fashion that events are being added to the map in `setupEvents()`.

Events can be attached on a per marker basis by attaching an `events` object with callback functions.

var main_marker = {
lat: 0.966,
lng: 2.02,
events: {
click: function(e) {
/* Act on event */
}
}
};

Within the callback, `this` contains an object with the original name given to the marker to allow you to reference the object of markers within the controller. If there’s a better way to do this, please let me know.

Currently no events are broadcasted to the root scope so these event callbacks are really only available to the current scope. I can forsee cases where this is an issue, but there are many cases where it isn’t.

Any feedback and suggestions greatly appreciated!