【发布时间】:2016-12-27 14:39:16
【问题描述】:
我正在尝试在 C# 的 Windows 窗体中使用 GMap。我已经创建了确切的路线,但是有什么方法可以在 GMaps.NET 中计算路线的距离和持续时间,除了调用 Google Distance Matrix Api 之外,还有没有为此目的实现的功能?
【问题讨论】:
标签: c# .net google-maps gmap.net
我正在尝试在 C# 的 Windows 窗体中使用 GMap。我已经创建了确切的路线,但是有什么方法可以在 GMaps.NET 中计算路线的距离和持续时间,除了调用 Google Distance Matrix Api 之外,还有没有为此目的实现的功能?
【问题讨论】:
标签: c# .net google-maps gmap.net
我正在寻找的函数名为“距离”。 这是获取路线距离的方法:
inicial = new PointLatLng(googleGeoCoding(txtorigin.Text).Item2,googleGeoCoding(txtorigin.Text).Item3);
final = new PointLatLng(googleGeoCoding(txtdest.Text).Item2, googleGeoCoding(txtdest.Text).Item3);
GDirections routedir;
var routefromtable = GMapProviders.GoogleMap.GetDirections(out routedir, inicial, final, chbxhighways.Checked, chbxtolls.Checked, rbtnwalking.Checked, false, false);
GMapRoute tablemaproute = new GMapRoute(routedir.Route, "Ruta ubication");
GMapOverlay tablerouteoverlay = new GMapOverlay("Capa de la ruta");
tablerouteoverlay.Routes.Add(tablemaproute);
gMapControl1.Overlays.Add(tablerouteoverlay);
gMapControl1.Zoom = gMapControl1.Zoom + 1;
gMapControl1.Zoom = gMapControl1.Zoom - 1;
double distance = tablemaproute.Distance;
MessageBox.Show(distance.ToString());
【讨论】: