Default Map Background

This commit is contained in:
ClemensFischer 2024-05-24 09:13:41 +02:00
parent 25dc5dc139
commit 3c907c3345
6 changed files with 11 additions and 7 deletions

View file

@ -1,4 +1,7 @@

// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// Copyright © 2024 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using Avalonia.Controls;
using System;

View file

@ -6,6 +6,7 @@ global using Avalonia;
using Avalonia.Animation;
using Avalonia.Animation.Easings;
using Avalonia.Controls;
using Avalonia.Media;
using Avalonia.Styling;
using System.Threading;
using System.Threading.Tasks;
@ -75,16 +76,12 @@ namespace MapControl
static MapBase()
{
BackgroundProperty.OverrideDefaultValue(typeof(MapBase), Brushes.White);
ClipToBoundsProperty.OverrideDefaultValue(typeof(MapBase), true);
Animation.RegisterCustomAnimator<Location, LocationAnimator>();
}
public MapBase()
{
MapProjectionPropertyChanged(MapProjection);
}
internal Size RenderSize => Bounds.Size;
protected override void OnSizeChanged(SizeChangedEventArgs e)

View file

@ -16,6 +16,7 @@ using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media;
#elif AVALONIA
using Avalonia.Media;
using Brush = Avalonia.Media.IBrush;
using DependencyProperty = Avalonia.AvaloniaProperty;
using UIElement = Avalonia.Controls.Control;
#endif
@ -60,7 +61,7 @@ namespace MapControl
private Location transformCenter;
private Point viewCenter;
private double centerLongitude;
private double maxLatitude = 90d;
private double maxLatitude = 85.05112878; // default WebMercatorProjection
private bool internalPropertyChange;
/// <summary>

View file

@ -24,6 +24,7 @@ using DispatcherTimer = Microsoft.UI.Dispatching.DispatcherQueueTimer;
using Avalonia.Controls;
using Avalonia.Media;
using Avalonia.Threading;
using Brush = Avalonia.Media.IBrush;
using DependencyProperty = Avalonia.AvaloniaProperty;
using ImageSource = Avalonia.Media.IImage;
#endif

View file

@ -23,6 +23,7 @@ using DispatcherTimer = Microsoft.UI.Dispatching.DispatcherQueueTimer;
using Avalonia.Controls;
using Avalonia.Media;
using Avalonia.Threading;
using Brush = Avalonia.Media.IBrush;
using DependencyProperty = Avalonia.AvaloniaProperty;
#endif

View file

@ -70,6 +70,7 @@ namespace MapControl
public MapBase()
{
// Set Background by Style to enable resetting by ClearValue in MapLayerPropertyChanged.
// There is no default Style in Generic.xaml because MapBase has no DefaultStyleKey property.
//
var style = new Style(typeof(MapBase));
style.Setters.Add(new Setter(BackgroundProperty, new SolidColorBrush(Colors.White)));