【问题标题】:GMap.NET C#, distance between 2 points without Google Distance Matrix ApiGMap.NET C#,没有谷歌距离矩阵 Api 的两点之间的距离
【发布时间】:2016-12-27 14:39:16
【问题描述】:

我正在尝试在 C# 的 Windows 窗体中使用 GMap。我已经创建了确切的路线,但是有什么方法可以在 GMaps.NET 中计算路线的距离和持续时间,除了调用 Google Distance Matrix Api 之外,还有没有为此目的实现的功能?

【问题讨论】:

    标签: c# .net google-maps gmap.net


    【解决方案1】:

    我正在寻找的函数名为“距离”。 这是获取路线距离的方法:

                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());
    

    【讨论】:

    • GDirections routedir;我的对象引用未设置为对象的实例,如何解决?
    猜你喜欢
    • 2011-09-21
    • 1970-01-01
    • 1970-01-01
    • 2017-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-12
    相关资源
    最近更新 更多