我正在尝试更改google.maps.Data类中某个功能的图标表示,以便在点击某个功能后,新图标会一直保留,直到另一个功能被点击为止。 。 .all同时保持mouseover
和mouseout
事件侦听器对其余功能保持活动状态。
我已经实现了所有功能,但使点击的功能图标保持为wx_click.png
一旦我将鼠标移开它,样式将恢复(根据代码)。我不想删除任何其他功能的mouseout
或mouseover
侦听器,只是已被点击的功能。
/* ~~ 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
});