我在谷歌地图上做了几个多边形。现在我想向多边形添加鼠标悬停(和鼠标悬停),这样当您将鼠标悬停在多边形上时,您可以看到该区域的名称。并且当您将鼠标移出时,名称就会消失(例如当您将鼠标悬停在浏览器中的按钮上时)
var map;
var infoWindow;
function initialize() {
var myLatLng = new google.maps.LatLng(50.88111111111, 3.889444444444);
var myOptions = {
zoom: 12,
center: myLatLng,
mapTypeId: google.maps.MapTypeId.TERRAIN
};
var poly;
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var polyCoords = [
verwissel(3.869506,50.906449),
verwissel(3.869654,50.905664),
verwissel(3.869934,50.904131),
verwissel(3.870310,50.902717),
verwissel(3.870471,50.901559),
];
poly = new google.maps.Polygon({
paths: HerzeleCoords,
strokeColor: "#FF0000",
strokeOpacity: 0.8,
strokeWeight: 3,
fillColor: "#FF0000",
fillOpacity: 0.35
});
google.maps.event.addListener(Poly, "mouseover", function(showtext("polyname"));
google.maps.event.addListener(Poly, "mouseover", function(do not show text anymore);
这就是我认为它的样子,但我不知道它是如何工作的。