2010-04-22 21 views
0

我試圖在Google Maps版本3中使用MVC對象。我似乎無法弄清楚爲什麼我的zoom_changed方法只調用一次。當我第一次加載地圖時,調用zoom_changed方法。但是當我放大地圖時不行。zoom_changed僅在Google Maps API版本3中使用MVC觸發一次

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(‘放大’,this.map.zoom)」?

+0

找到解決方案,你需要指定一個bindTo未設置!即。 this.bindTo('zoom',this.map); – fredrik 2010-04-22 12:55:53

+0

我很高興你解決了它。您可能想要將其作爲答案發布,並接受它。 – 2010-04-22 14:56:09

回答

1

找到解決方案。請對我的原帖發表評論。

下面引用註釋:

找到了解決辦法,你需要指定一個bindTo沒有設置!即。 this.bindTo('zoom',this.map);