删除/禁用google.maps.Data类中功能子集的事件侦听器

时间:2015-04-21 00:03:31

标签: javascript google-maps-api-3 mouseevent geojson

我正在尝试更改google.maps.Data类中某个功能的图标表示,以便在点击某个功能后,新图标会一直保留,直到另一个功能被点击为止。 。 .all同时保持mouseovermouseout事件侦听器对其余功能保持活动状态。

我已经实现了所有功能,但使点击的功能图标保持为wx_click.png一旦我将鼠标移开它,样式将恢复(根据代码)。我不想删除任何其他功能的mouseoutmouseover侦听器,只是已被点击的功能。

/* ~~ Mouseover listener ~~ */
map.data.addListener('mouseover', function(event) {
    map.data.revertStyle();
    map.data.overrideStyle(event.feature, {
        icon: '/img/wx_mo.png', 
        title: 'weather station',
    })
});

/* ~~ Mouseout listener ~~*/
mouseoutEventListener = map.data.addListener('mouseout', function(event) {
    map.data.revertStyle();
});

/* ~~ Click listener ~~ */
map.data.addListener('click', function(event) {

    map.data.overrideStyle(event.feature, {icon: '/img/wx_click.png'});

// do other stuff
});

0 个答案:

没有答案