|
@@ -238,6 +238,7 @@ public static class MapControlEx
|
|
|
internal PopupMenu rectMenu;
|
|
|
internal Action<(double starLon, double startLat, double centerLon, double centerLat,
|
|
|
double endLon, double endLat, double lonRange, double latRange)> mOnRectChanged;
|
|
|
+ internal Action<(double Lon, double Lat)> onClickChanged;
|
|
|
internal MapItemStorage mMapStorage;
|
|
|
internal MapItemStorage mMapStorageFixed;
|
|
|
internal MapPolyline distinctPath;
|
|
@@ -955,6 +956,71 @@ public static class MapControlEx
|
|
|
innerData.barM.EndInit();
|
|
|
return ctrl;
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 使用航迹
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="ctrl"></param>
|
|
|
+ /// <param name="onClickChanged">点击事件返回当前经纬度</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static MapControl UseHJ(this MapControl ctrl, Action<(double Lon, double Lat)> onClickChanged = null)
|
|
|
+ {
|
|
|
+ var btnHJ = new BarButtonItem() { Caption = "航迹" };
|
|
|
+ btnHJ.ImageOptions.SvgImage = SvgHelper.CreateMarkDot();
|
|
|
+ btnHJ.Tag = ctrl;
|
|
|
+
|
|
|
+ var innerData = ctrl.Tag as InnerData;
|
|
|
+ innerData.onClickChanged = onClickChanged;
|
|
|
+ btnHJ.ItemClick += (sender, e) =>
|
|
|
+ {
|
|
|
+ ctrl.MapEditor.SetEditMode();
|
|
|
+ ctrl.MouseClick += AddHJPoint;
|
|
|
+ ctrl.DoubleClick += (sender1, e1) =>
|
|
|
+ {
|
|
|
+ ctrl.MouseClick -= AddHJPoint;
|
|
|
+ };
|
|
|
+ };
|
|
|
+ innerData.barM.BeginInit();
|
|
|
+ innerData.barM.Items.Add(btnHJ);
|
|
|
+ innerData.mapMenu.LinksPersistInfo.Add(new LinkPersistInfo(btnHJ));
|
|
|
+ innerData.barM.EndInit();
|
|
|
+ return ctrl;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 添加航迹点
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="T"></typeparam>
|
|
|
+ /// <param name="ctrl"></param>
|
|
|
+ /// <param name="item"></param>
|
|
|
+ public static void AddHJPosItem<T>(this MapControl ctrl, T item) where T : PosData, new()
|
|
|
+ {
|
|
|
+ if (item.PosLon > 180) return;
|
|
|
+ var innerData = ctrl.Tag as InnerData;
|
|
|
+ var mapItem = new MapDot()
|
|
|
+ {
|
|
|
+ EnableHighlighting = DefaultBoolean.True,
|
|
|
+ EnableSelection = DefaultBoolean.False,
|
|
|
+ CanMove = false,
|
|
|
+ Visible = item.Visible,
|
|
|
+ IsHitTestVisible = true,
|
|
|
+ Fill = ColorHelper.IsHtmlColor(item.ColorKey) ? ColorTranslator.FromHtml(item.ColorKey) : ColorHelper.GetColor(item.ColorKey),
|
|
|
+ Size = _dotSize,
|
|
|
+ Tag = item,
|
|
|
+ Location = new GeoPoint(item.PosLat, item.PosLon),
|
|
|
+ ToolTipPattern="dd"
|
|
|
+ };
|
|
|
+ innerData.mMapStorage.Items.Add(mapItem);
|
|
|
+
|
|
|
+ }
|
|
|
+ private static void AddHJPoint(object sender, MouseEventArgs e)
|
|
|
+ {
|
|
|
+ var innerData = (sender as MapControl).Tag as InnerData;
|
|
|
+ var ctrl = sender as MapControl;
|
|
|
+ var geoPoint = ctrl.ScreenPointToCoordPoint(e.Location) as GeoPoint;
|
|
|
+ innerData.onClickChanged?.Invoke((geoPoint.Longitude, geoPoint.Latitude));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/// <summary>
|
|
|
/// 为地图添加右键标点功能
|
|
@@ -1379,7 +1445,7 @@ public static class MapControlEx
|
|
|
string identify = "DrawPoint_";
|
|
|
if (lines == null || !lines.Any()) return;
|
|
|
var innerData = ctrl.Tag as InnerData;
|
|
|
-
|
|
|
+
|
|
|
List<MapDot> list = new List<MapDot>();
|
|
|
var color = ColorHelper.GetColor(title);
|
|
|
for (int i = 0; i < lines.Count(); i++)
|
|
@@ -1440,9 +1506,9 @@ public static class MapControlEx
|
|
|
/// <param name="title"></param>
|
|
|
/// <param name="lines"></param>
|
|
|
/// <param name="isClear">是否清除上次绘制</param>
|
|
|
- public static void DrawLine(this MapControl ctrl, string title, IEnumerable<(double lon, double lat)> lines, bool isClear = true)
|
|
|
+ public static void DrawCXLine(this MapControl ctrl, string title, IEnumerable<(double lon, double lat)> lines, bool isClear = true)
|
|
|
{
|
|
|
- string identify = "DrawLine_";
|
|
|
+ string identify = "DrawCXLine_";
|
|
|
if (lines == null || !lines.Any()) return;
|
|
|
var innerData = ctrl.Tag as InnerData;
|
|
|
if (isClear)
|
|
@@ -1456,13 +1522,14 @@ public static class MapControlEx
|
|
|
var polyLine = new MapPolyline()
|
|
|
{
|
|
|
Stroke = Color.Red,
|
|
|
- StrokeWidth = 2,
|
|
|
+ StrokeWidth = 3,
|
|
|
CanMove = false,
|
|
|
Visible = true,
|
|
|
IsHitTestVisible = true,
|
|
|
Tag = $"{identify}{title}",
|
|
|
+ ToolTipPattern= title,
|
|
|
+
|
|
|
};
|
|
|
- polyLine.TitleOptions.Pattern = title;
|
|
|
foreach (var item in lines)
|
|
|
{
|
|
|
if (double.IsNaN(item.lat) || double.IsNaN(item.lon)) continue;
|
|
@@ -1513,7 +1580,7 @@ public static class MapControlEx
|
|
|
/// <param name="wcKm"></param>
|
|
|
/// <param name="dots"></param>
|
|
|
/// <param name="patterncount"></param>
|
|
|
- public static void DrawGdopLineTwo(this MapControl ctrl, string wcKm, IEnumerable<(double lon, double lat)> dots, int patterncount,bool isClear=true)
|
|
|
+ public static void DrawGdopLineTwo(this MapControl ctrl, string wcKm, IEnumerable<(double lon, double lat)> dots, int patterncount, bool isClear = true)
|
|
|
{
|
|
|
if (dots == null || !dots.Any()) return;
|
|
|
string identify = "DrawGdopLine_";
|
|
@@ -1907,6 +1974,7 @@ public static class MapControlEx
|
|
|
ctrl.MouseEnter += MapControl_MouseEnter;
|
|
|
ctrl.DoubleClick += EndDistinct;
|
|
|
}
|
|
|
+
|
|
|
private static void MarkDot_ItemClick(object sender, ItemClickEventArgs e)
|
|
|
{
|
|
|
var ctrl = e.Item.Tag as MapControl;
|
|
@@ -2637,5 +2705,4 @@ public static class MapControlEx
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-}
|
|
|
-
|
|
|
+}
|