Event handler arguments
The way of passing arguments to event handlers is a bit confusing for me. Why not to go simple and preserve original google maps api in this case?
// source code
getEventHandler = (eventName) ->
->
scope.events[eventName].apply scope, [_m, eventName, arguments]
//bind handler
events:
'click': (map, eventName, eventArguments) ->
console.log eventArguments[0].latLng // looks strange
The events attributes maps directly onto the Google Maps event API.
Can you suggest a less confusing interface, or is this just a documentation issue? On Apr 21, 2014 9:04 PM, "aki-russia" [email protected] wrote:
The way of passing arguments to event handlers is a bit confusing for me. Why not to go simple and preserve original google maps api in this case?
// source code getEventHandler = (eventName) -> -> scope.events[eventName].apply scope, [_m, eventName, arguments]
//bind handler events: 'click': (map, eventName, eventArguments) -> console.log eventArguments[0].latLng // looks strange
— Reply to this email directly or view it on GitHubhttps://github.com/nlaplante/angular-google-maps/issues/378 .
As for me, less confusing could be same as in google maps.
But, I understand that map and eventName was added for some reason.
My suggestion is to pass arguments as it in google-maps, but also concat additional from directive:
events:
'click': (event, map, eventName) ->
console.log event.latLng // looks better
Second way is to concat original arguments to directive's:
events:
'click': (map, eventName, event) ->
console.log event.latLng //looks even better
Removing and/or reordering the map and eventName parameters from the callback function would break many existing applications.
We'll update the documentation for the events attribute, as they don't document the existence of these two callback function parameters.
Added documentation for events callback function parameters in [website-develop] to be released with v1.1. See 1275ad98dfcef946485edf59392d8b67d45f8520