apneadiving / Google-Maps-for-Rails

Enables easy Google map + overlays creation in Ruby apps
https://apneadiving.github.io/
MIT License
2.26k stars 382 forks source link

Adding event handlers in v2.x #406

Closed davetapley closed 10 years ago

davetapley commented 10 years ago

I can see some references to addListener in the source, but I can't get my head round how to apply one.

My intuition tells me it should work like this:

handler = Gmaps.build("Google")
handler.buildMap provider: {}, internal: { id: "map" }, ->
  handler.addListener 'bounds_changed', ->
    console.log(handler.getMap().getBounds().getNorthEast().toString())

But apparently not.

apneadiving commented 10 years ago

Dont bother with it, just do it the way you know:

handler = Gmaps.build("Google")
handler.buildMap provider: {}, internal: { id: "map" }, ->
  google.maps.event.addListener handler.getMap(), 'bounds_changed', ->
     console.log(handler.getMap().getBounds().getNorthEast().toString())
davetapley commented 10 years ago

@apneadiving okay then! Thanks for the quick reply :smile:

Would you consider merging this into the wiki? Knowing to call handler.getMap() to get the underlying google.maps.Map is that part which wasn't obvious.

apneadiving commented 10 years ago

Feel free to edit the wiki :)

Sent from my iPad

On 08 Dec 2013, at 01:20, Dave Tapley notifications@github.com wrote:

@apneadiving okay then! Thanks for the quick reply

Would you consider merging this into the wiki? Knowing to call handler.getMap() to get the underlying google.maps.Map is that part which wasn't obvious.

— Reply to this email directly or view it on GitHub.

davetapley commented 10 years ago

:+1: