c# - Gmap.Net route 的点之间没有线条

标签 c# winforms gmap.net

我在 Windows 窗体上使用 Gmap.Net,我想在收到对象位置时绘制对象的轨迹,为此我使用 Routes 。当我向路线添加点时, map 上看不到任何线条,但是当我更改 map 的缩放比例时,它们会出现在 map 上。此外,当我在向路线添加点后设置 map 位置时(gMapControl1.Position = new PointLatLng(...)),它可以正常工作,并且我可以在 map 上看到路线,任何想法?我的代码如下。

void NewDataReceived(DeviceInfo deviceinf)
{
    //---some codes
    //----For the first time I add layer and route 
    if (deviceOverLay == null)
    {
        deviceOverLay = new GMapOverlay(deviceinf.DeviceId.ToString());
        gMapControl1.Overlays.Add(deviceOverLay);
        deviceRoute = new GMapRoute(new List<PointLatLng>(), deviceinf.DeviceName);
        deviceOverLay.Routes.Add(deviceRoute);
        //Add all your points here
        deviceRoute.Points.Add(new PointLatLng(deviceinf.Latitude, deviceinf.Longitude));
        deviceRoute.Tag = deviceinf;
    }
    else
    {
        deviceOverLay.Routes[0].Points.Add(new PointLatLng(deviceinf.Latitude, deviceinf.Longitude));
    }

    //if I call this line it works, but I don't want it
    // gMapControl1.Position = new PointLatLng(deviceinf.Latitude, deviceinf.Longitude);  
    //---some codes
}

最佳答案

尝试使用

gMapControl1.UpdateRouteLocalPosition(deviceRoute);

这会更新本地位置并进行重绘。

关于c# - Gmap.Net route 的点之间没有线条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39470378/

相关文章:

c# - 如何获取两个地理坐标之间的所有点

c# - GMap.NET 路由返回 null

c# - Blazor 服务器端是否有任何热重载?

c# - 通过 C# 将 SSRS RDL 导出为 PDF

c# - 始终以基本形式处理 PreviewKeyDown 事件

c# - 这个阻塞线程如何调用 "freeing"本身?

c# - 一个工作的 GMap.NET 应用程序源

c# - 如何正确初始化和填充多维数组?

c# - 如何在将记录插入数据库后立即在组合框中显示主键 C#?

c# - 如何处理 DataGridView 编辑控件的绘制?