Bing获取光标位置

Bing get cursor location

本文关键字:位置 光标 获取 Bing      更新时间:2023-09-26

我正在使用必应地图V7.0开发一个web应用程序我已经创建了一个功能齐全的上下文菜单,但现在我想使用驾驶方向来实现它,然后我需要在右键单击和菜单弹出时获得光标的长度。这是在旧的Bing地图版本中创建它的方法。但是它已经不工作了

e.view.LatLong.Latitude

所以如果有人知道查找光标位置的新方法,请告诉我。

改成:

e.target
    .tryPixelToLocation(new Microsoft.Maps.Point(e.getX(), e.getY()))
    .latitude

我在MouseEventArgs文档页面上找到了代码:

map = new Microsoft.Maps.Map(
    document.getElementById("myMap"),
    {credentials:"Bing Maps Key"}
);
Microsoft.Maps.Events.addHandler(map, 'click', displayEventInfo);
// ...
function displayEventInfo(e) {
    if (e.targetType == "map") {
        var point = new Microsoft.Maps.Point(e.getX(), e.getY());
        var loc = e.target.tryPixelToLocation(point);
        document.getElementById("textBox").value = loc.latitude
            + ", " + loc.longitude;
    }
}