Files
annotations/Azaion.Annotator/Controls/MapMatcherEventHandler.cs
T
2025-05-27 13:26:37 +03:00

28 lines
1.0 KiB
C#

using Azaion.Common.Services;
using GMap.NET;
using GMap.NET.WindowsPresentation;
using MediatR;
namespace Azaion.Annotator.Controls;
public class MapMatcherEventHandler(MapMatcher mapMatcher) : INotificationHandler<GPSMatcherResultEvent>
{
public Task Handle(GPSMatcherResultEvent result, CancellationToken cancellationToken)
{
mapMatcher.Dispatcher.Invoke(() =>
{
var marker = new GMapMarker(new PointLatLng(result.Latitude, result.Longitude));
var ann = mapMatcher.Annotations[result.Index];
marker.Shape = new CircleVisual(marker, System.Windows.Media.Brushes.Blue)
{
Text = result.Image
};
mapMatcher.SatelliteMap.Markers.Add(marker);
ann.Lat = result.Latitude;
ann.Lon = result.Longitude;
mapMatcher.SatelliteMap.Position = new PointLatLng(result.Latitude, result.Longitude);
mapMatcher.SatelliteMap.ZoomAndCenterMarkers(null);
});
return Task.CompletedTask;
}
}