我已经设置了我的制造商动态调用信息窗口并在鼠标悬停时重定向到URL:
google.maps.event.addListener(marker, 'mouseover', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
location.href='/places/'+locations[i][3];
}
})(marker, i));
我如何修改它以便信息窗口部分在鼠标悬停时发生,但location.href部分仅在点击时发生?我一直在玩一些排列,我无法让它发挥作用。
谢谢!
修改 我找到了答案:我想我错过了分号或其他东西:
google.maps.event.addListener(marker, 'mouseover', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
location.href='/spots/'+locations[i][3];
}
})(marker, i));