gpt4 book ai didi

javascript - IE 11 浏览器上的 Bing map ,鼠标单击事件仅在我们打开兼容模式时有效

转载 作者:行者123 更新时间:2023-11-28 08:10:47 26 4
gpt4 key购买 nike

我正在使用 Ajax 从 Javascript 调用 C# 并从数据库加载数据。

我使用了以下文章来显示图钉和信息框。

http://blogs.msdn.com/b/rbrundritt/archive/2013/11/08/multiple-pushpins-and-infoboxes-in-bing-maps-v7.aspx?CommentPosted=true#commentmessage

当我打开兼容模式时,我的代码在 IE 11 上运行良好,

但是当兼容模式关闭时,鼠标点击事件不会被 Javascript 函数接收。

我尝试使用 Chrome,但遇到了同样的问题。

<%@ Page Title="" Language="C#" MasterPageFile="~/Maps.Master" AutoEventWireup="true" CodeBehind="BingMaps.aspx.cs" Inherits="MyMaps.secure.BingMaps" %>

....

<asp:ScriptManager ID="ScriptManager" runat="server"
EnablePageMethods="true" />

<asp:Literal ID="Literal1" runat="server">
</asp:Literal>

var map = null,信息框,数据层; $(文档).ready(函数(){ 获取 map ();

    });
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);
}

最佳答案

SVG 标准中的指针事件在 IE 11、chrome 和 firefox 中的实现与以前的版本略有不同。

我必须使用 pointer-events:none 设置容器 div,以接收鼠标事件。

<div class="divRow" style="pointer-events: none;">
<div id="MapHolder" style="width:900px; height:540px;display:block; margin-left:5px;top:2px; ">
</div>
</div>

关于javascript - IE 11 浏览器上的 Bing map ,鼠标单击事件仅在我们打开兼容模式时有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29281497/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com