私のバックボーンビューはを実装していgoogle.maps.OverlayView()
ます。
このビューにはコンテンツ用のいくつかのdivが含まれており、コンテナdivでマウスオーバー/アウトを処理し、divを含む2つのイベントをクリックする必要があります。
必要なイベントを取得できる唯一の方法はgoogle.maps.event.addDomListener
、ビューでを使用することです。このようなもの(コードのコピーと貼り付け):
var MarkerView = MasterView.extend({
events:{
//These events will never be fired
'click .icon-context':function () {},
'mouseout':function (event) {}
},
render:function(){
//this renders the google.maps.OverlayView by implementing onAdd, draw, onRemove
var that = this;
this.overlay.onAdd = function(){
//Code for adding the OverLayView omitted here
that.listeners_ = [
google.maps.event.addDomListener(that.overlay.el, 'mouseout', function () {
//This event should not be handled here
}),
google.maps.event.addDomListener($(that.overlay.el).find('.icon-context').first()[0], 'click', function () {
//This event should not be handled here
}),
];
};
}
});
ビューロジックのコア部分は、マップ上およびほぼ同じものを表示/処理するリストで使用したいので、再利用可能である必要があります。ビューをGoogleマップのイベントリスナーにバインドすると、イベント処理のためにかなりの量のコードを複製する必要があります。そうするのは正確には正しくないと感じています。
ビューが内部でホストされている場合、ビューでイベントを「ネイティブに」処理するにはどうすればよいですか。google.maps.OverlayView