Model view controller zoom_在使用MVC的Google Maps API版本3中只更改了一次触发器

Model view controller zoom_在使用MVC的Google Maps API版本3中只更改了一次触发器,model-view-controller,google-maps,google-maps-api-3,Model View Controller,Google Maps,Google Maps Api 3,我正在尝试使用谷歌地图版本3中的MVC对象。我似乎不明白为什么我的zoom\u changed方法只被调用一次。当我第一次加载地图时,会调用zoom\u changed方法。但当我在地图上缩放时就不会了 function MarkerWidget (options) { this.setValues(options); this.set('zoom', this.map.zoom); var marker = new google.maps.Marker({

我正在尝试使用谷歌地图版本3中的MVC对象。我似乎不明白为什么我的
zoom\u changed
方法只被调用一次。当我第一次加载地图时,会调用
zoom\u 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不设置!即:this.bindTo('zoom',this.map)

找到解决方案后,需要指定一个bindTo不设置!即:this.bindTo('zoom',this.map);我很高兴你解决了这个问题。你可能想把它作为一个答案,并接受它。