Tso*_*koa 7 google-maps mouseover infowindow google-maps-api-3
我有一个带有InfoWindows标记的页面,我在Click上打开了.我决定在MouseOver上打开InfoWindows,它正在运行.
但我发现必须将鼠标移动到InfoWindow的十字架上以关闭它对于这些懒惰的互联网访问者来说有点苛刻.所以我在Click of the Marker上添加了一个Close事件,它也正常工作.
我无法解决的问题是能够在Marker Click上重新打开 InfoWindow,而不必使用mouseout以便能够在标记上重新鼠标悬停.
我的代码:
google.maps.event.addListener(CalMarker, 'mouseover', function() {
infowindow.setContent(contentStringCal);
infowindow.open(map,CalMarker);
});
google.maps.event.addListener(CalMarker, 'click', function() {
infowindow.close(map,CalMarker);
});
Run Code Online (Sandbox Code Playgroud)
任何人都可以通过点击标记帮我重新打开窗口吗?
提前致谢
PS:无法在帖子的开头说"嗨",这很奇怪.
试试这个:
google.maps.event.addListener(CalMarker, 'mouseover', function() {
//open the infowindow when it's not open yet
if(contentStringCal!=infowindow.getContent())
{
infowindow.setContent(contentStringCal);
infowindow.open(map,CalMarker);
}
});
google.maps.event.addListener(CalMarker, 'click', function() {
//when the infowindow is open, close it an clear the contents
if(contentStringCal==infowindow.getContent())
{
infowindow.close(map,CalMarker);
infowindow.setContent('');
}
//otherwise trigger mouseover to open the infowindow
else
{
google.maps.event.trigger(CalMarker, 'mouseover');
}
});
//clear the contents of the infwindow on closeclick
google.maps.event.addListener(infowindow, 'closeclick', function() {
infowindow.setContent('');
});
Run Code Online (Sandbox Code Playgroud)
演示:http://jsfiddle.net/doktormolle/JXqLa/
归档时间: |
|
查看次数: |
16355 次 |
最近记录: |