将必应地图当前位置与必应地图 REST 合并 计算路线



嗨,我已经整理了如何在必应中映射我的当前位置

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
   <head>
      <title></title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
      <script type="text/javascript">
         var map;
         function GetMap()
         {
            // Set the map options
            var mapOptions = {credentials:"xxxxxxx"};

            // Initialize the map
            map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), mapOptions);
            // Initialize the location provider
            var geoLocationProvider = new Microsoft.Maps.GeoLocationProvider(map);
            // Get the user's current location
            geoLocationProvider.getCurrentPosition({successCallback:displayCenter});

         }
         function displayCenter(args)
         {
            // Display the user location when the geo location request returns
            alert("The user's location is " + args.center);
         }

      </script>
   </head>
   <body onload="GetMap();">
      <div id='mapDiv' style="position:relative; width:400px; height:400px;"></div>       
   </body>
</html>

我还整理了如何在指定开始/结束坐标时计算路线

工作
<cfhttp  timeout="10000" url="http://dev.virtualearth.net/REST/V1/Routes/Walking?wp.0=-27.491030,153.095764&wp.1=-27.476757,153.040493&o=xml&key=xxxxxxxxxxxxxx">

我想做的是能够将上述 2 个结合起来,以便我首先运行当前位置,然后将生成的坐标传递给计算路线,以便 wp.0=#current 位置坐标#

您可以在 JavaScript: http://msdn.microsoft.com/en-us/library/gg427607.aspx 中轻松使用 Bing Maps REST 服务。尽管不需要它,因为 Bing 地图 V7 控件有一个方向模块,用于为你包装服务:http://msdn.microsoft.com/en-us/library/hh312802.aspx

要对应用程序进行路由调用,只需更新 displayCenter 函数,即可使用 REST 或方向管理器使用路由服务。您还可以在此处找到在交互式 SDK 中使用必应地图的方向模块的示例:http://www.bingmapsportal.com/ISDK/AjaxV7#DirectionsModule4

最新更新