mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 10:06:30 +00:00
28 lines
1.0 KiB
C#
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;
|
|
}
|
|
} |