Javascript Virtual Earth V6.3(Bing)地图控件中高缩放级别的多段线问题

Javascript Virtual Earth V6.3(Bing)地图控件中高缩放级别的多段线问题,javascript,asp.net,bing-maps,polyline,virtual-earth,Javascript,Asp.net,Bing Maps,Polyline,Virtual Earth,我有一个带有Virtual Earth V6.3控件的应用程序,使用纯javascript添加多段线,如以下嵌入在单个HTML5网页中的示例代码片段所示: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>VE Map with Polyline</title> <script type="text/javascrip

我有一个带有Virtual Earth V6.3控件的应用程序,使用纯javascript添加多段线,如以下嵌入在单个HTML5网页中的示例代码片段所示:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>VE Map with Polyline</title>
    <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.3"></script>
    <script type="text/javascript">
        function MapLoad() {
            // load map
            var _map = new VEMap('Map');
            _map.LoadMap();

            // center point in NY City
            var _center = new VELatLong(40.75, -73.99);

            // zoom level
            _map.SetCenterAndZoom(_center, 14);

            // set Map style
            _map.SetMapStyle(VEMapStyle.Shaded);

            // polyline layer
            var _layerPolyline = new VEShapeLayer();

            // sample polyline array of coordinates
            var _arrPoints = [];
            _arrPoints.push(new VELatLong(40.78, -73.984));
            _arrPoints.push(new VELatLong(40.76, -73.989));
            _arrPoints.push(new VELatLong(40.75, -73.99));
            _arrPoints.push(new VELatLong(40.74, -73.991));
            _arrPoints.push(new VELatLong(40.73, -73.992));
            _arrPoints.push(new VELatLong(40.72, -73.993));
            _arrPoints.push(new VELatLong(40.72, -73.994));
            _arrPoints.push(new VELatLong(40.73, -73.995));
            _arrPoints.push(new VELatLong(40.73, -73.996));
            _arrPoints.push(new VELatLong(40.74, -73.997));

            // polyline object properties
            var _polyLine= new VEShape(VEShapeType.Polyline, _arrPoints);
            _polyLine.HideIcon();
            _polyLine.SetLineColor(new VEColor(0, 0, 255, 1));
            _polyLine.SetFillColor(new VEColor(0, 0, 255, 0));
            _polyLine.SetLineWidth(4);

            // add polyline to layer
            _layerPolyline.AddShape(_polyLine);

            // add layer to map
            _map.AddShapeLayer(_layerPolyline);
        }
    </script>
</head>
<body onload="MapLoad();">
    <div id="Map" style="position:absolute; height:98%; width:98%;"></div>
</body>
</html>

带多段线的虚拟地图
函数MapLoad(){
//负荷图
var_map=新的VEMap('map');
_LoadMap();
//纽约市中心
var_中心=新韦拉特朗(40.75,-73.99);
//缩放级别
_map.setcenter和zoom(_center,14);
//设置地图样式
_map.SetMapStyle(VEMapStyle.Shaded);
//多段线图层
var_layerPolyline=新的VEShapeLayer();
//坐标的多段线阵列示例
var_arrPoints=[];
_arrPoints.push(新VELatLong(40.78,-73.984));
_arrPoints.push(新VELatLong(40.76,-73.989));
_arrPoints.push(新VELatLong(40.75,-73.99));
_arrPoints.push(新VELatLong(40.74,-73.991));
_arrPoints.push(新VELatLong(40.73,-73.992));
_arrPoints.push(新VELatLong(40.72,-73.993));
_arrPoints.push(新VELatLong(40.72,-73.994));
_arrPoints.push(新VELatLong(40.73,-73.995));
_arrPoints.push(新VELatLong(40.73,-73.996));
_arrPoints.push(新VELatLong(40.74,-73.997));
//多段线对象特性
var _polyLine=新的VEShape(VEShapeType.polyLine,_arrPoints);
_polyLine.HideIcon();
_polyLine.SetLineColor(新的VEColor(0,0,255,1));
_polyLine.SetFillColor(新的向量颜色(0,0,255,0));
_多段线。设置线宽(4);
//将多段线添加到图层
_layerPolyline.AddShape(_polyLine);
//将图层添加到地图
_map.AddShapeLayer(_layerPolyline);
}
它在任何缩放级别都可以正常工作。然而,在实际应用中,当使用ASP.NET 4.5 web窗体时,本质上相同的代码会产生奇怪的结果,即:多段线在高缩放级别(大约大于15)时消失

Q:关于问题的根本原因和解决方法有什么想法吗?Thx


更新问题通过升级到Bing Maps AJAX控件7.0版解决(工作::公交路线多段线在任何缩放级别都可见)。感谢Ricky Brundritt(@rbrundritt)。

可能的问题与缺少的UTF-9元标记或doctype有关。V6.3非常旧,需要指定以下metatag和doctype:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
您可以在此处找到有关如何创建Bing地图帐户和密钥的文档:

我建议为“公共网站”创建一个“基本”键。这将允许您每年进行125000笔免费交易


尽管如此,您不应该使用v6.3。它在5年前被V7取代,不久将接近寿命的尽头。v6.3的文档在一年多前离线,作为该版本结束生命的一部分。

非常感谢您的回答(已接受)和富有洞察力的评论。似乎VE 6.3不适合任何有前瞻性的应用程序开发人员,但我很惊讶它需要web应用程序的密钥/凭据(据我所知,以前的版本不需要)。我有一个用于桌面Win应用程序的密钥,我将其用于我的WPF开发,但不用于web应用程序。更令人困惑的是:如果我将这个键以纯文本的形式放入javascript中(根据您的示例),那么它将在整个世界可见。请你对这个问题发表评论好吗?感谢和问候,Alex BellBing Maps在版本5前后引入了一种身份验证方法。随着v6的发布,此身份验证方法从id/密码方法更改为密钥方法。map控件在没有身份验证的情况下工作,但违反了使用条款。不使用密钥是一种法律风险。另一个风险是,由于您没有对地图进行身份验证,Bing地图团队不知道您正在使用v6.3,因此您没有收到任何关于其生命终止的通知。任何人都可以创建一个键,它可以以纯文本显示。注意,即使在WPF中也很容易提取密钥。谢谢@rbrundritt,我明白你的意思。事实上,我有我的Bing账户的所有3个键,包括你提到的那一个,所以我将在我的web应用程序中使用它。除了这个密钥/凭据问题,V6似乎是旧的和有缺陷的技术,所以我认为要么升级到V7,要么切换到谷歌地图。无论如何,谢谢你的时间和关心。我最好的,亚历克斯B。
_map = new VEMap('MapNYC');
_map.SetCredentials("YOUR_BING_MAPS_KEY");
_map.LoadMap();