huafu / ember-google-map

An Ember addon to include a google-map Ember friendly component in your apps.
http://huafu.github.io/#/ember?name=ember-google-map
MIT License
87 stars 34 forks source link

How to send arguments with events #51

Closed oskarrough closed 9 years ago

oskarrough commented 9 years ago

Hi, I followed your example https://github.com/huafu/ember-google-map/wiki/Provided-Tools-and-Classes-%28API%29#example-use-case-responding-to-events and now I can trigger an action when you click a marker.

How can I pass, say, the marker title with the event?

Usecase: I have a list of locations on the left and a map on the right. When you tap a marker, I need to scroll to the corresponding list-item for that marker.

huafu commented 9 years ago

See just above the example, there: you can define the target, and the action you'll define will receive that target. Anyway by default the target is the view where you defined the googleEvents property, so to access the marker's model, you can use Ember's controller property of the view:

theActionNameYouDefined: function(target) {
  var marker = target.get('controller.model'); // here is the clicked marker's record/object
  //...
}

Also see the example here.

oskarrough commented 9 years ago

Thanks so much!