【问题标题】:Bing Maps v8 - DirectionsManager - dragDropCompleted event errorBing Maps v8 - DirectionsManager - dragDropCompleted 事件错误
【发布时间】:2017-01-14 10:04:01
【问题描述】:

我正在尝试使用 DirectionsManager 类的 Bing Maps v8。文档描述了一个 dragDropCompleted 事件,如下链接:

https://msdn.microsoft.com/pt-br/library/hh312802.aspx

我已经创建了一个基于 Bing Maps Interactive SDK 的示例:

http://www.bing.com/api/maps/sdk/mapcontrol/isdk#directionsEvent_directionsUpdated+JS

但是当我运行我的脚本时出现错误:

错误:无法读取未定义的属性“添加”

有人可以帮帮我吗?

 var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
    credentials: 'Your Bing Maps Key',
    center: new Microsoft.Maps.Location(47.606209, -122.332071),
    zoom: 12
 });

 Microsoft.Maps.loadModule('Microsoft.Maps.Directions', function () {
    var directionsManager = new Microsoft.Maps.Directions.DirectionsManager(map);
    // Set Route Mode to driving
    directionsManager.setRequestOptions({ routeMode: Microsoft.Maps.Directions.RouteMode.driving });

    var waypoint1 = new Microsoft.Maps.Directions.Waypoint({ address: 'Redmond', location: new Microsoft.Maps.Location(47.67683029174805, -122.1099624633789) });
    var waypoint2 = new Microsoft.Maps.Directions.Waypoint({ address: 'Seattle', location: new Microsoft.Maps.Location(47.59977722167969, -122.33458709716797) });
    directionsManager.addWaypoint(waypoint1);
    directionsManager.addWaypoint(waypoint2);

    Microsoft.Maps.Events.addHandler(directionsManager, 'dragDropCompleted', function () {
        console.log('Drag & Drop Complete!');
    })

    directionsManager.calculateDirections();
 });

【问题讨论】:

    标签: maps bing-maps bing bing-api


    【解决方案1】:

    Bing Maps V8 中没有 dragDropCompleted 事件。您引用的文档适用于较旧的 V7 地图 API。在 V8 中,只需使用方向更新事件。这是 DirectionsManager 的 V8 文档:https://msdn.microsoft.com/en-US/library/mt750375.aspx

    【讨论】:

    • 我的错。对不起! Tnx!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-17
    • 1970-01-01
    相关资源
    最近更新 更多