|
@@ -25,10 +25,13 @@ public partial class EquipmentMapsView : UserControl
|
|
|
= AvaloniaProperty.Register<EquipmentMapsView, ObservableCollection<Marker>>(nameof(EquipmentMarkers), new());
|
|
|
|
|
|
public static readonly StyledProperty<Point> CoordinatesProperty
|
|
|
- = AvaloniaProperty.Register<EquipmentMapsView, Point>(nameof(JobMarkers), new());
|
|
|
+ = AvaloniaProperty.Register<EquipmentMapsView, Point>(nameof(Coordinates), new());
|
|
|
|
|
|
public static readonly StyledProperty<int> ZoomLevelProperty
|
|
|
- = AvaloniaProperty.Register<EquipmentMapsView, int>(nameof(EquipmentMarkers), new());
|
|
|
+ = AvaloniaProperty.Register<EquipmentMapsView, int>(nameof(ZoomLevel), new());
|
|
|
+
|
|
|
+ public static readonly StyledProperty<Rect> BoxProperty
|
|
|
+ = AvaloniaProperty.Register<EquipmentMapsView, Rect>(nameof(Box), new());
|
|
|
|
|
|
private readonly MemoryLayer _jobLayer;
|
|
|
private readonly MemoryLayer _equipmentLayer;
|
|
@@ -53,12 +56,26 @@ public partial class EquipmentMapsView : UserControl
|
|
|
get => GetValue(ZoomLevelProperty);
|
|
|
}
|
|
|
|
|
|
+ public Rect Box
|
|
|
+ {
|
|
|
+ get => GetValue(BoxProperty);
|
|
|
+ }
|
|
|
+
|
|
|
static EquipmentMapsView()
|
|
|
{
|
|
|
JobMarkersProperty.Changed.AddClassHandler<EquipmentMapsView>(JobMarkersChanged);
|
|
|
EquipmentMarkersProperty.Changed.AddClassHandler<EquipmentMapsView>(EquipmentMarkersChanged);
|
|
|
CoordinatesProperty.Changed.AddClassHandler<EquipmentMapsView>(CoordinatesChanged);
|
|
|
ZoomLevelProperty.Changed.AddClassHandler<EquipmentMapsView>(ZoomLevelChanged);
|
|
|
+ BoxProperty.Changed.AddClassHandler<EquipmentMapsView>(BoxChanged);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void BoxChanged(EquipmentMapsView view, AvaloniaPropertyChangedEventArgs args)
|
|
|
+ {
|
|
|
+ var p1 = SphericalMercator.FromLonLat(view.Box.Left, view.Box.Top);
|
|
|
+ var p2 = SphericalMercator.FromLonLat(view.Box.Right, view.Box.Bottom);
|
|
|
+ view.Map.Map.Navigator.ZoomToBox(new(p1.x, p1.y, p2.x, p2.y));
|
|
|
+ view.Map.Map.Navigator.ZoomOut();
|
|
|
}
|
|
|
|
|
|
private static void ZoomLevelChanged(EquipmentMapsView view, AvaloniaPropertyChangedEventArgs args)
|
|
@@ -100,6 +117,7 @@ public partial class EquipmentMapsView : UserControl
|
|
|
Bind(EquipmentMarkersProperty, new Binding(nameof(EquipmentMapsViewModel.EquipmentMarkers)));
|
|
|
Bind(CoordinatesProperty, new Binding(nameof(EquipmentMapsViewModel.Coordinates)));
|
|
|
Bind(ZoomLevelProperty, new Binding(nameof(EquipmentMapsViewModel.ZoomLevel)));
|
|
|
+ Bind(BoxProperty, new Binding(nameof(EquipmentMapsViewModel.Box)));
|
|
|
|
|
|
_jobLayer = CreateJobLayer();
|
|
|
_equipmentLayer = CreateEquipmentLayer();
|