Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/447.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在Bing地图中自定义路线-保存路线/方向以备将来使用_Javascript_Bing Maps - Fatal编程技术网

Javascript 如何在Bing地图中自定义路线-保存路线/方向以备将来使用

Javascript 如何在Bing地图中自定义路线-保存路线/方向以备将来使用,javascript,bing-maps,Javascript,Bing Maps,我是Bing地图的新手,我正在尝试在两个航路点之间画一个方向 以下是html页面代码: <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>title</title> <script type='text/javascript' src='http://www.bing.com/api/maps/mapcontrol?c

我是Bing地图的新手,我正在尝试在两个航路点之间画一个方向

以下是html页面代码:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>title</title>
  <script type='text/javascript' src='http://www.bing.com/api/maps/mapcontrol?callback=GetMap' async defer></script>
</head>
<style type="text/css">
    #myMap {
    position: relative;
    width: 80%;
    height: 550px;
}
</style>
<body onload="GetMap();">
<div id="myMap"></div>
<script type="text/javascript">
   function GetMap()
   {
    var map = new Microsoft.Maps.Map('#myMap', {
    credentials: 'Ah21BgC5b223JVupbpDgKZjsT7ZSZ_cFzdhTxsBc8pVWP6fClhEeGznfJhtzBc3q',
    zoom: 18
    });
    var location1=new Microsoft.Maps.Location(51.5079, -0.1247);
    var location2=new Microsoft.Maps.Location(51.5095, -0.1234);

    Microsoft.Maps.loadModule('Microsoft.Maps.Directions', function () {
                //Create an instance of the directions manager.
                directionsManager = new Microsoft.Maps.Directions.DirectionsManager(map);
                //Create waypoints to route between.
                var wp1 = new Microsoft.Maps.Directions.Waypoint({location:location1});
                var wp2 = new Microsoft.Maps.Directions.Waypoint({ location:location2});

                directionsManager.addWaypoint(wp1);
                directionsManager.addWaypoint(wp2);
                //Calculate directions.
                directionsManager.calculateDirections();
            });
    }
</script>
</body>
</html>

标题
#我的地图{
位置:相对位置;
宽度:80%;
高度:550px;
}
函数GetMap()
{
var map=new Microsoft.Maps.map(“#myMap”{
凭证:“AH21BGC5B223JVUPDPGKZJST7ZSZ_cFzdhTxsBc8pVWP6fClhEeGznfJhtzBc3q”,
缩放:18
});
var location1=新的Microsoft.Maps.Location(51.5079,-0.1247);
var location2=新的Microsoft.Maps.Location(51.5095,-0.1234);
Microsoft.Maps.loadModule('Microsoft.Maps.Directions',函数(){
//创建方向管理器的实例。
directionsManager=新的Microsoft.Maps.Directions.directionsManager(地图);
//创建要在之间路由的航路点。
var wp1=新的Microsoft.Maps.Directions.Waypoint({location:location1});
var wp2=新的Microsoft.Maps.Directions.Waypoint({location:location2});
directionsManager.addWaypoint(wp1);
directionsManager.addWaypoint(wp2);
//计算方向。
DirectionManager.calculateDirections();
});
}
它正在工作并在两个航路点之间创建方向

我的问题是,是否有必要更改此路线并保存路线/方向以备将来使用

我试过了,但运气不好

任何帮助都将不胜感激