[英]No line between points in Gmap.Net route
我在 Windows 窗體上使用 Gmap.Net,我想在接收到它的位置時繪制對象的軌跡,為此我使用了Routes
。 當我向路線添加點時,地圖上看不到線,但是當我更改地圖的縮放比例時,它們會出現在地圖上。 此外,當我在路線上添加一個點( gMapControl1.Position = new PointLatLng(...)
)后設置地圖的位置時,它工作正常,我在地圖上看到了路線,知道嗎? 我的代碼如下。
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);
這會更新本地位置並進行重繪。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.