【发布时间】: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