以编程方式向Bing地图添加折线

本文关键字:地图 添加 折线 Bing 编程 方式 | 更新日期: 2023-09-27 18:17:18

我有路由名称在我的下拉列表和数组与事件对应的日志/日志(折线)。如何从代码后面发送这个日志/日志到javascript?

<head>
  <title></title>
    <meta name="viewport" content="width=device-width,initial-scale=1.0"/>
    <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
    <script type="text/javascript">         
      function GetMap() {           
          // Initialize the map              
          var mapOptions = {
              credentials: "xxxx",
              center: new Microsoft.Maps.Location( 9.74, 2.425),
              mapTypeId: Microsoft.Maps.MapTypeId.road,
              zoom: 13,
              showScalebar: false
          }
          var map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), mapOptions);
          var lineVertices = new Array(new Microsoft.Maps.Location(<%@new pts%>));
          var line = new Microsoft.Maps.Polyline(lineVertices);
          map.entities.push(line);
      }
    </script>
   <style type="text/css">
       #form1
       {
           width: 480px;
       }
   </style>

<body onload="GetMap();" style="height: 18px; width: 480px">
   <form id="form1" runat="server">
    <div id='listDiv' style="width:480px; height:30px" >          
        <asp:DropDownList ID="listPicker" runat="server" Height="25px" Width="218px" 
            onselectedindexchanged="listPicker_SelectedIndexChanged">
        </asp:DropDownList>          
     </div>          
      <div id='mapDiv' style="position:absolute; width:480px; height:740px; top: 38px; ">
   </div>
   </form>

protected void listPicker_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (listPicker.SelectedIndex == 1)
        {
            pts = new double[,]  {  
            { 9.6990549318566, 2.4374476373222},
            { 9.6991218770296, 2.4379291260322},
            { 9.6994116428257, 2.4376508334228},
            { 9.6995069262757, 2.4356545805958},
            { 9.6999728977379, 2.4356384873417},
            { 9.6999845469968, 2.4326612353352},
            { 9.7056459228308, 2.432768526198},
            { 9.7088142924775, 2.4295498753801},
            { 9.7228377868168, 2.4293138409868},
            { 9.7228098349562, 2.4276401425615}};
        }else{...}
    }

有一种方法发送这个点到js?

以编程方式向Bing地图添加折线

你可以试试

     Dim oGeocodeList As New List(Of [String])()
    oGeocodeList.Add(" '37.968002524107035, 23.702445030212402' ")
    oGeocodeList.Add(" '37.969, 23.705445030212402' ")
    oGeocodeList.Add(" '37.97, 23.709445030212402' ")
      Dim geocodevalues = String.Join(",", oGeocodeList.ToArray())
    ClientScript.RegisterArrayDeclaration("locationList", geocodevalues)

和javascript中的

 var locationList;

对不起,vb代码。