我在 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/