我正在尝试在地图上用谷歌地图 v3 中的相关信息窗口画一条线。我的鼠标悬停似乎可以正常工作,但似乎无法打开信息窗口。
function drawScheduledCommand(radius, map, latlng, angle, infoText){
var spherical = google.maps.geometry.spherical;
twoThirdRadius = radius / 3 * 2 ;
oneThirdRadius = radius / 3 ;
twoThirdPoint = new spherical.computeOffset(center, twoThirdRadius, angle);
endPoint = new spherical.computeOffset(twoThirdPoint, oneThirdRadius, angle);
var positionLineOptions = {
strokeColor: "#FFFFF0",
strokeOpacity: 0.99,
strokeWeight: 2,
fillColor: "#FFFFF0",
fillOpacity: 0.99,
map: map,
zIndex: 5,
path: [twoThirdPoint, endPoint]
}
line = new google.maps.Polyline(positionLineOptions);
var lineInfoWindow = new google.maps.InfoWindow();
lineInfoWindow.setContent(infoText);
lineInfoWindow.open(map);
google.maps.event.addListener(line, 'mouseover', function() {
console.log(infoText);
lineInfoWindow.open(map);
});
google.maps.event.addListener(line, 'mouseout', function() {
lineInfoWindow.close();
});
}