【问题标题】:I have a problem passing values to bing maps route service in IE7我在 IE7 中将值传递给 bing 地图路由服务时遇到问题
【发布时间】:2011-09-12 08:42:13
【问题描述】:

我有这段代码可以计算两个地方之间的路线

function createDrivingRoute()
{
    $("#nav").html("");//CLEAR HTML
    if (!directionsManager) { 
        createDirectionsManager();
    }
    directionsManager.resetDirections();
    // Set Route Mode to driving 

    directionsManager.setRequestOptions({
        drivingPolylineOptions:{
            strokeColor: new Microsoft.Maps.Color(150, 255, 51, 51), strokeThickness: 8
        },
        distanceUnit: 
                    Microsoft.Maps.Directions.DistanceUnit.kilometers,
                    routeOptimization: Microsoft.Maps.Directions.RouteOptimization.shortestDistance,
                    routeMode: Microsoft.Maps.Directions.RouteMode.driving
        });
    var seattleWaypoint = new Microsoft.Maps.Directions.Waypoint({
        address: fromtxt ,location: new Microsoft.Maps.Location(plat, plng)
    });
    directionsManager.addWaypoint(seattleWaypoint);
    var tacomaWaypoint = new Microsoft.Maps.Directions.Waypoint({
        address: totxt, location: new Microsoft.Maps.Location(mlat, mlng)
    });
    directionsManager.addWaypoint(tacomaWaypoint);

    // Set the element in which the itinerary will be rendered
    directionsManager.setRenderOptions({
        itineraryContainer: document.getElementById('nav')
    });
    directionsManager.calculateDirections();
}

其中“plat, plng, mlat, mlng”是全局变量; "i" 使用 jquery "attr" 方法设置它们。 此示例适用于除 ie7 和 ie8 之外的所有浏览器。

它给了我这个错误:

line:2
char :141845
Error : 'undefined' is null or not an object
code:0

它停止工作

//

使用 firefox 控制台时出现此错误,但它仍然有效

[10:37:03.054] uncaught exception: InvalidOperation: Matrix3D.invert

【问题讨论】:

    标签: jquery bing-maps


    【解决方案1】:

    对于所有受此问题困扰并通过谷歌来到这里发现没有答案的人

    在发送之前将变量解析为浮动
    像这样

    parseFloat(plat);
    

    它应该可以工作 虽然我认为微软开发人员应该将任何收到的变量转换为他们的 API 求正确的形式!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-12-26
      • 1970-01-01
      • 1970-01-01
      • 2010-11-05
      • 2021-12-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多