【问题标题】:zoom_changed only triggers once in Google Maps API version 3 using MVCzoom_changed 仅在使用 MVC 的 Google Maps API 版本 3 中触发一次
【发布时间】:2010-04-22 12:41:37
【问题描述】:

我正在尝试在 Google 地图版本 3 中使用 MVC 对象。我似乎无法弄清楚为什么我的 zoom_changed 方法只被调用一次。当我第一次加载地图时,会调用 zoom_changed 方法。但当我放大地图时不会。

function MarkerWidget (options) {
    this.setValues(options);
    this.set('zoom', this.map.zoom);

    var marker = new google.maps.Marker({
            icon : this.icon,
            mouseOverIcon : this.mouseOverIcon,
            orgIcon : this.orgIcon
    });

    marker.bindTo('map', this);
    marker.bindTo('position', this);

    google.maps.event.addListener(marker, 'mouseover', this.onmouseover);
    google.maps.event.addListener(marker, 'mouseout', this.onmouseout);
}

MarkerWidget.prototype = new google.maps.MVCObject();
MarkerWidget.prototype.zoom_changed = function () {
    $.log(this, new Date());
}

地图对象不应该触发缩放事件并通知所有具有“this.set('zoom', this.map.zoom)”的对象吗?

【问题讨论】:

  • 找到了解决办法,需要指定一个bindTo不设置! IE。 this.bindTo('zoom', this.map);
  • 很高兴你解决了这个问题。您可能希望将其作为答案发布并接受。

标签: model-view-controller google-maps google-maps-api-3


【解决方案1】:

找到了解决办法。请参阅我对原始帖子的评论。

以下参考评论:

找到解决办法,需要指定一个未设置的bindTo! IE。 this.bindTo('zoom', this.map);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-19
    • 2013-08-25
    • 1970-01-01
    • 1970-01-01
    • 2011-09-23
    • 1970-01-01
    • 1970-01-01
    • 2012-07-04
    相关资源
    最近更新 更多