jbdemonte / gmap3

jQuery plugin to create Google maps
http://gmap3.net
668 stars 198 forks source link

Unexpected behavior when calling on/once #119

Closed berarma closed 7 years ago

berarma commented 7 years ago

My code looks like:

var gmap3 = $("#map").gmap3({...});
gmap3.marker({...});
gmap3.on("click", function () {
    console.log("click");
});

It seems the event is attached to the marker, not the map. I had a hard time understanding this. I haven't seen any explanation in the docs. The chaining section is clear about what the following code does:

var gmap3 = $("#map").gmap3({...});
gmap3.marker({...}).on("click", function () {
    console.log("click");
});

But I didn't expect both snippets to do the same. Is that correct or may I have some other error? Is it documented somewhere?

Thanks.

jbdemonte commented 7 years ago

This is the same in fact, each function returns the gmap3 instance, and each call are stacked into an internal promise