谷歌地图API V3鼠标悬停多边形?鼠标、多边形、地图、API

2023-09-10 15:57:10 作者:视你如命

我建设使用谷歌版API,因为它是这样快的地图。从本质上讲,它是一个区域与多边形在地区的约30个城市的地图。当用户将鼠标悬停在一个城市,我想将fillColor获得较轻的,然后返回到它在的mouseout正常状态。当用户点击,它重定向到另一个页面。

I'm building a map using the google v3 api because it is way faster. Essentially, it's a map of an area with about 30 cities with polygons over the regions. When a user hovers over a city, I want the fillColor to get lighter, and then return to it's normal state on mouseout. when a user click, it redirects them to another page.

单击事件工作得很好。不过,翻翻v3的API文档,它好像谷歌已经实现单击,双击,鼠标移动,鼠标按下和MouseUp作为事件触发,但没有悬停或鼠标悬停,或mouseout事件。

The click event works just fine. But, looking through the v3 API documentation, it seems as if Google has implemented click, doubleclick, mousemove, mousedown and mouseup as event triggers, but no hover, or mouseover, or mouseout.

真的吗?吉兹。我会考虑和淘汰工作将优先级高于向下和向上。

Really? Geez. I'd think over and out would be higher priority than down and up.

总之,有其他人遇到过吗?我错了吗?还是有解决方法吗?

Anyway, has anybody else come across this? Am I wrong? Or is there a workaround?

感谢您在您的帮助, 萧蔷

Thank you in advance for your help, Stephanie

推荐答案

以下工作:

google.maps.event.addListener(polygon,"mouseover",function(){
 this.setOptions({fillColor: "#00FF00"});
}); 

google.maps.event.addListener(polygon,"mouseout",function(){
 this.setOptions({fillColor: "#FF0000"});
});