// 更新目标航迹 private void UpdateTrackPoint(Model3D model) { List <TrackPoint> trackPoints = trackMgr.GetTrackPoints(model.ModelName); if (trackPoints == null || trackPoints.Count <= 1) { return; // 如果没有点,或者最多只有一个点,则返回不进行航迹绘制 } var layer = mapLogic.AddLayer(model.LayerName); if (layer == null) { return; } string lineName = model.ModelName + "line"; var line = layer.GetElement(lineName); if (line == null) { Kml kmlLine = new Kml(); kmlLine.Placemark.Name = lineName; KmlLineString linekml = new KmlLineString(); linekml.Color = Color.Red; linekml.Width = 1; List <MapLngLat> plist = new List <MapLngLat>(); for (int i = 0; i < trackPoints.Count; i++) { var point = new MapLngLat(trackPoints[i].Position.Lng, trackPoints[i].Position.Lat, trackPoints[i].Position.Alt); plist.Add(point); } linekml.PositionList = plist; linekml.Rasterize = false; kmlLine.Placemark.Graph = linekml; var result = layer.AddElement(kmlLine); } else { IMFLine lineElement = line as IMFLine; if (line == null) { return; } List <MapLngLat> plist = new List <MapLngLat>(); for (int i = 0; i < trackPoints.Count; i++) { var point = new MapLngLat(trackPoints[i].Position.Lng, trackPoints[i].Position.Lat, trackPoints[i].Position.Alt); plist.Add(point); } lineElement.UpdatePosition(plist); } }
// 更新航迹 private void UpdateTrackPoint(Plane plane) { List <TrackPoint> trackPoints = trackMgr.GetTrackPoints(plane.Name); if (trackPoints == null || trackPoints.Count <= 1) { return; } var layer = mapLogic.AddLayer(plane.LayerName); if (layer == null) { return; } string lineName = plane.Name + "line"; var line = layer.GetElement(lineName); if (line == null) { Kml kmlLine = new Kml(); kmlLine.Placemark.Name = lineName; KmlLineString lineKml = new KmlLineString(); lineKml.Color = System.Drawing.Color.Blue; lineKml.Width = 1; List <MapLngLat> plist = new List <MapLngLat>(); for (int i = 0; i < trackPoints.Count; i++) { var point = new MapLngLat(trackPoints[i].Position.Lng, trackPoints[i].Position.Lat, trackPoints[i].Position.Alt); plist.Add(point); } lineKml.PositionList = plist; kmlLine.Placemark.Graph = lineKml; var ret = layer.AddElement(kmlLine); } else { IMFLine lineElement = line as IMFLine; if (line == null) { return; } List <MapLngLat> plist = new List <MapLngLat>(); for (int i = 0; i < trackPoints.Count; i++) { var point = new MapLngLat(trackPoints[i].Position.Lng, trackPoints[i].Position.Lat, trackPoints[i].Position.Alt); plist.Add(point); } lineElement.UpdatePosition(plist); } }