代码之家  ›  专栏  ›  技术社区  ›  Eric Palakovich Carr

在GoogleMapsv3中将类方法绑定到事件?

  •  3
  • Eric Palakovich Carr  · 技术社区  · 15 年前

    在Google Maps API的v2中,可以使用gevent.bind函数将map事件绑定到类方法:

    GEvent.bind(this.drag_marker, "dragstart", this, this.start_dragging_route);
    

    在上面的示例中,假设这是来自prototype.init函数的链接,其中 start_dragging_route 是类内的方法。

    似乎bind方法已经不存在了,至少文档中没有。如果这是真的,我有一种方法来解决它,但它有点难看,所以我想听听其他解决这个问题的方法。

    如何在谷歌地图api v3中实现gevent.bind函数?

    1 回复  |  直到 15 年前
        1
  •  4
  •   Eric Palakovich Carr    15 年前

    哦,对了。关闭。杜赫。

    var self = this;
    google.maps.event.addListener(this.drag_marker, "dragstart", function(latlng) {
        self.start_dragging_route(latlng);
    });