private void readTastitemButton_Click(object sender, EventArgs e) { int id, ret, index = 1; int wpCount = 0; MissionItemStruct missionItemStruct = new MissionItemStruct(); mapOverlayMarker.Markers.Clear(); mapOverlayMarker.Routes.Clear(); do { id = IbusMessageClass.Send_read_tastitem(index); if (id < 0) { MessageBox.Show("设置航点点错误"); } do { ret = IbusMessageClass.Get_ret_tastitem(id, ref missionItemStruct); Thread.Sleep(5); } while (ret > 0); if (ret < 0) { MessageBox.Show("设置航点错误:" + ret.ToString()); } else if (ret == 0) { // MessageBox.Show("设置航点成功:" + ret.ToString()); PointLatLng pos = new PointLatLng(missionItemStruct.x, missionItemStruct.y); wpCount = missionItemStruct.total; mapOverlayMarker.Markers.Add(new GMarkerGoogle(MyMap.gps84_To_Gcj02(pos), GMarkerGoogleType.green)); mapOverlayMarker.Markers[mapOverlayMarker.Markers.Count - 1].ToolTipText = mapOverlayMarker.Markers.Count.ToString(); if (mapOverlayMarker.Markers.Count >= 2) { List <PointLatLng> listPoint = new List <PointLatLng>(); listPoint.Add(mapOverlayMarker.Markers[mapOverlayMarker.Markers.Count - 2].Position); listPoint.Add(mapOverlayMarker.Markers[mapOverlayMarker.Markers.Count - 1].Position); GMapRoute gMapRoute = new GMapRoute(listPoint, ""); gMapRoute.Stroke.Color = Color.Yellow; gMapRoute.Stroke.Width = 2; mapOverlayMarker.Routes.Add(gMapRoute); } this.myMap.Refresh(); } } while (index++ < wpCount); }
public static extern int Get_ret_tastitem(int id, ref MissionItemStruct item);
public static extern int Send_write_tastitem(ref MissionItemStruct item);