Javascript Bing地图在IE 11浏览器上,只有当我们打开兼容模式时,鼠标点击事件才起作用
我使用Ajax从Javascript调用C#,并从数据库加载数据 我用下面的文章来展示图钉和信息框 我的代码在IE 11上运行得很好,当我打开兼容模式时 但是当兼容性模式关闭时,Javascript函数不会接收鼠标单击事件 我尝试使用Chrome,但我也遇到了同样的问题Javascript Bing地图在IE 11浏览器上,只有当我们打开兼容模式时,鼠标点击事件才起作用,javascript,jquery,css,bing-maps,Javascript,Jquery,Css,Bing Maps,我使用Ajax从Javascript调用C#,并从数据库加载数据 我用下面的文章来展示图钉和信息框 我的代码在IE 11上运行得很好,当我打开兼容模式时 但是当兼容性模式关闭时,Javascript函数不会接收鼠标单击事件 我尝试使用Chrome,但我也遇到了同样的问题 <%@ Page Title="" Language="C#" MasterPageFile="~/Maps.Master" AutoEventWireup="true" CodeBehind="BingMaps.asp
<%@ Page Title="" Language="C#" MasterPageFile="~/Maps.Master" AutoEventWireup="true" CodeBehind="BingMaps.aspx.cs" Inherits="MyMaps.secure.BingMaps" %>
。。。。
var map=null,信息框,数据层;
$(文档).ready(函数(){
GetMap()
});
函数GetMap(){
//初始化映射
map=new Microsoft.Maps.map(document.getElementById(“MapHolder”),
{凭证:“lincensekey”,缩放:2});
dataLayer=新的Microsoft.Maps.EntityCollection();
map.entities.push(数据层);
var infoboxLayer=new Microsoft.Maps.EntityCollection();
map.entities.push(infoboxLayer);
infobox=new Microsoft.Maps.infobox(new Microsoft.Maps.Location(0,0),{visible:false,offset:new Microsoft.Maps.Point(0,20)});
infoboxLayer.push(infobox);
GetLocations(RequestCompletedCallback、RequestFailedCallback);
}
函数AddData(映射点){
对于(变量i=0,len=MapPoints.length;i ”+
服务错误:“+消息+”
”+
状态代码:“+statusCode+”
”+
异常类型:“+exceptionType+”
”+
“Timedout:”+Timedout);
}
SVG标准中的指针事件在IE 11、chrome和firefox中的实现与以前版本略有不同
我必须将容器div设置为指针事件:none,以接收鼠标事件
<div class="divRow" style="pointer-events: none;">
<div id="MapHolder" style="width:900px; height:540px;display:block; margin-left:5px;top:2px; ">
</div>
</div>
我对它做了更多的工作,并将其确定为以下内容:我们在IE 11上看到鼠标事件的问题,只有当地图保持div在
<asp:Literal ID="Literal1" runat="server">
</asp:Literal>
});
function GetMap() {
// Initialize the map
map = new Microsoft.Maps.Map(document.getElementById("MapHolder"),
{ credentials: "lincensekey", zoom: 2 });
dataLayer = new Microsoft.Maps.EntityCollection();
map.entities.push(dataLayer);
var infoboxLayer = new Microsoft.Maps.EntityCollection();
map.entities.push(infoboxLayer);
infobox = new Microsoft.Maps.Infobox(new Microsoft.Maps.Location(0, 0), { visible: false, offset: new Microsoft.Maps.Point(0, 20) });
infoboxLayer.push(infobox);
PageMethods.GetLocations(RequestCompletedCallback, RequestFailedCallback);
}
function AddData(MapPoints) {
for (var i = 0, len = MapPoints.length; i < len; ++i)
{
var pushpin = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(parseFloat(MapPoints[i].lat),parseFloat(MapPoints[i].lon))
, {
icon: MapPoints[i].group,
height: 50, width: 60, text: MapPoints[i].city
});
pushpin.Title = MapPoints[i].name;
pushpin.description = MapPoints[i].desc;
Microsoft.Maps.Events.addHandler(pushpin, 'click', displayInfobox);
dataLayer.push(pushpin);
}
}
function displayInfobox(e) {
if (e.targetType == 'pushpin') {
infobox.setLocation(e.target.getLocation());
infobox.setOptions({ visible: true, title: e.target.Title, description: e.target.description });
}
}
function RequestCompletedCallback(result) {
result = eval(result);
AddData(result);
}
function RequestFailedCallback(error) {
var stackTrace = error.get_stackTrace();
var message = error.get_message();
var statusCode = error.get_statusCode();
var exceptionType = error.get_exceptionType();
var timedout = error.get_timedOut();
alert("Stack Trace: " + stackTrace + "<br/>" +
"Service Error: " + message + "<br/>" +
"Status Code: " + statusCode + "<br/>" +
"Exception Type: " + exceptionType + "<br/>" +
"Timedout: " + timedout);
}
<div class="divRow" style="pointer-events: none;">
<div id="MapHolder" style="width:900px; height:540px;display:block; margin-left:5px;top:2px; ">
</div>
</div>