bing映射两个位置之间的直线

丹尼尔·古斯塔夫森(Daniel Gustafsson)

我正在使用bing地图。到目前为止,它在两个位置之间划了一条线,但使用了道路。我希望它是飞机视图,以便它仅画出两点之间的直线并告诉我它们之间的距离。我现在正在使用这个:

var startwaypoint = new Microsoft.Maps.Directions.Waypoint({ location: new Microsoft.Maps.Location(lat1, lon1) });
bingDirections.addWaypoint(startwaypoint);
// end
var endwaypoint = new Microsoft.Maps.Directions.Waypoint({ location: new Microsoft.Maps.Location(lat2, lon2) });
bingDirections.addWaypoint(endwaypoint);

我在其中输入的坐标为lat1和lon1。

尼古拉斯·布纳特(Nicolas Boonaert)

我们的Alastair同事写了一篇文章,在Bing Maps V7上绘制测地线(大圆)。我敢肯定,您可以从他的文章中获取重要内容,并改编JavaScript代码,以便它可以在您的C#控件上使用。

参见文章:http : //alastaira.wordpress.com/2011/06/27/geodesics-on-bing-maps-v7/

这是您应该能够在C#中使用的JavaScript代码:

    // Creates geodesic approximation of the lines drawn between an array
// of points, by dividing each line into a number of segments.
function ToGeodesic(points, n) {
  if (!n) { n = 32 }; // The number of line segments to use
  var locs = new Array();
  for (var i = 0; i < points.length - 1; i++) {
    with (Math) {
      // Convert coordinates from degrees to Radians
      var lat1 = points[i].latitude * (PI / 180);
      var lon1 = points[i].longitude * (PI / 180);
      var lat2 = points[i + 1].latitude * (PI / 180);
      var lon2 = points[i + 1].longitude * (PI / 180);
      // Calculate the total extent of the route
      var d = 2 * asin(sqrt(pow((sin((lat1 - lat2) / 2)), 2) + cos(lat1) * cos(lat2) * pow((sin((lon1 - lon2) / 2)), 2)));
      // Calculate  positions at fixed intervals along the route
      for (var k = 0; k <= n; k++) {
        var f = (k / n);
        var A = sin((1 - f) * d) / sin(d);
        var B = sin(f * d) / sin(d);
        // Obtain 3D Cartesian coordinates of each point
        var x = A * cos(lat1) * cos(lon1) + B * cos(lat2) * cos(lon2);
        var y = A * cos(lat1) * sin(lon1) + B * cos(lat2) * sin(lon2);
        var z = A * sin(lat1) + B * sin(lat2);
        // Convert these to latitude/longitude
        var lat = atan2(z, sqrt(pow(x, 2) + pow(y, 2)));
        var lon = atan2(y, x);
        // Create a Location (remember to convert back to degrees)
        var p = new Microsoft.Maps.Location(lat / (PI / 180), lon / (PI / 180));
        // Add this to the array
        locs.push(p);
      }
    }
  }
  return locs;

}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在两个位置之间获取路径

在iOS中的GMSMapView上的两个位置之间绘制路线

获取两个位置之间的路线点

mysql中的ST_Distance_Sphere无法提供两个位置之间的准确距离

R中地球上两个位置之间的距离

如何使用mapView和CLLocationManager在iOS Swift中绘制两个位置之间的方向

快速计算两个位置之间的距离

通过从EditText输入纬度和经度来计算两个位置之间的距离

如何使用Android在Google Map中的两个位置之间绘制折线?

Mkmapview中两个位置之间的多条路线

计算Excel工作表中两个位置之间的地理坐标距离

如何从用户输入获取两个位置之间的距离

无法使用ReactJS在OpenLayers中的两个位置之间绘制默认线

计算两个位置之间距离的更快方法(邮政编码)

如何在两个位置之间连续移动GameObject?

检查两个位置之间的距离,以KM为单位

寻找两个位置之间的距离

如何在iPhone应用程序中找到两个位置之间的方向?

Swift-在字符串的两个位置之间查找子字符串

给定纬度和经度,计算两个位置之间的行驶/行驶距离(必应地图)

bash:清除两个位置之间的字符串

在两个位置之间随机生成一个SKSpriteNode

使用Google Map API计算两个位置之间的距离

如何在两个位置之间更改文本的颜色?

iOS中两个位置之间的估计时间

获取java android中两个位置之间的距离

如何通过道路计算两个位置之间的距离?

如何使用谷歌距离矩阵获得两个位置之间的距离

在 Kotlin 中查找两个位置之间的距离