将焦点设置在google地图's InfoWindow上,将鼠标移到上面
Set focus on google map's InfoWindow on marker mouseover
我想将信息窗口聚焦在鼠标悬停在标记上。只要他停留在信息窗口,窗口就会打开。下面是我的代码
content="<div class='info_content' id='info"+obj.customer_id+"'><span>"+j+".</span><h1><a href='<?php echo Mage::getUrl() ?>"+obj.identifier+"<?php echo $suffix; ?>'>"+obj.company.substr(0, 28)+"</a> </h1><br /><p>"+address+"</p><p>"+Math.round(obj.distance)+" Km Away</p><br /><button type='button' value='Get Direction' class='button_input' onclick='closeInfoWindow(),calcRoute("+obj.latitude+","+obj.longitude+")' name='Get Direction'>Get Direction</button></div>";
marker = new google.maps.Marker({
position: position,
map: map,
title: obj.company,
icon:icon,
});
if(i==0)
{
map.setCenter(marker.getPosition())
}
google.maps.event.addListener(marker,'mouseover', (function(marker,content,infowindow){
return function() {
infowindow.close();
infowindow.setContent(content);
infowindow.open(map,marker);
jQuery("#info"+obj.customer_id).focus();
};
})(marker,content,infowindow));
google.maps.event.addListener(marker,'mouseout', (function(marker,content,infowindow){
return function() {
};
})(marker,content,infowindow));
除非您设置tabindex
属性(如果我没有错,您可以使用此属性关注任何元素),否则不可能对div元素进行关注。focus动作通常用于表单/文本元素。
我做了一个工作示例(参见jsFiddle):
window.onload = function(){
var map = new google.maps.Map(document.getElementById('map'), {
center: new google.maps.LatLng(22.669, 77.709),
zoom: 5,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var content="<div class='info_content' id='info01' tabindex='1'>hello world</div>";
var infowindow = new google.maps.InfoWindow();
var marker = new google.maps.Marker({
position: new google.maps.LatLng(22.669, 77.709),
map: map
});
google.maps.event.addListener(marker, 'mouseover', function(){
infowindow.setContent(content);
infowindow.open(map, marker);
});
google.maps.event.addListener(marker, 'mouseout', function(){
//
});
google.maps.event.addListener(infowindow, 'domready', function(){
$('#info01').focus();
});
};
相关文章:
- EaseJS拖放;放下(动画CC)电影剪辑的鼠标坐标
- 当鼠标悬停在文本中的单词上时显示警报
- JsFiddle上的鼠标事件不起作用
- 每当您在选择器内移动鼠标时,悬停功能就会重复
- 如何在鼠标悬停时在另一个图像上滑动图像.
- 鼠标悬停事件影响列表中所有行中的按钮,而不仅仅是特定按钮
- 将鼠标旋转限制为特定的度数
- 跟踪jqplot垂直折线图的鼠标位置
- 边栏按钮和infoWindow是否可能有不同的内容
- node-webkit-从父窗口捕获iframe鼠标事件
- 悬停下拉菜单即使在鼠标移出后也保持活动状态
- Javascript-在视频中跟踪鼠标位置
- JQuery UI可拖动潜水与滚动棒到鼠标
- 如何在jquery中找到鼠标滚轮/触摸移动事件的走向
- 在鼠标悬停时展开列表
- jQuery悬停在没有鼠标悬停的情况下启动
- 鼠标输入在 YUI 的 chrome 中不起作用
- 鼠标悬停时如何居中放大背景图像
- 鼠标光标-用于wordpress网站
- 将焦点设置在google地图's InfoWindow上,将鼠标移到上面