谷歌地图事件-获取点击元素的父级
Google maps event - get parent of clicked element
我有一个函数,可以用来创建新对象"claster"。在每个冲突是标记从谷歌地图API。我想点击这个标记并访问claster.icons[]。我正在函数声明中绑定点击事件。怎么做?
代码
function newClaster(_center){
this.centerIco = _center;
this.center = this.centerIco.getPosition();
this.icons = [];
this.icons.push(this.centerIco);
this.addIcon = function(_icon){this.icons.push(_icon)};
this.marker = new google.maps.Marker({
position : this.center,
icon : {
url : 'map/circle.png',
scaledSize : new google.maps.Size(40,40),
size : new google.maps.Size(40,40),
},
map:map,
});
this.setCenter = function(ctr){
this.centerIco = ctr;
this.center = ctr.getPosition();
}
this.findCenter = function(){
this.centerIco = this.icons[parseInt((this.icons.length)%2)];
this.center = this.centerIco.getPosition();
}
google.maps.event.addListener(this.marker, 'click', function(){
this.icons
});
}
我正在绑定点击标记。
添加一个函数并在单击时将标记发送给它,然后您可以通过访问标记对象来获得图标:
google.maps.event.addListener(this.marker, 'click', getIcons(this));
function getIcons(marker){
console.log(marker.icons);
}
相关文章:
- 元素事件处理程序到EXT.js面板中
- 浏览器中的javascript和td元素事件属性
- 主干清理元素事件
- 影响类的所有成员而不是一个元素事件的插件正在发生
- AngularJS - ngRepeat.在 ng 重复重新渲染后,需要将焦点集中在相同的元素事件上
- 在jQuery中,如何触发mootools中添加的元素事件
- 允许 Raphael/SVG 元素事件通过顶部分层的 HTML 触发
- CanJS未来元素事件绑定
- 重新选择所选选项时,Javascript/jQuery选择元素事件
- 类变量在元素事件中不可见
- 修改元素'事件函数的参数
- 如何过滤掉事件处理程序中的子元素事件
- 要求Javascript关注多个元素事件的模式
- 允许先触发其他绑定元素事件
- Firefox扩展不能覆盖元素事件
- 如何获取"mouseup"之后的元素事件完成
- 用于文档防止元素事件的Onclick事件
- 如何获取触发“onclick”的元素事件
- 向由子元素事件触发的表单元格添加类/从中删除类
- JavaScript在元素加载后立即绑定元素事件