diff --git a/Directory.Build.props b/Directory.Build.props
index 78880c07..0a4b5520 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -3,7 +3,7 @@
XAML Map Control
Clemens Fischer
Copyright © 2025 Clemens Fischer
- 14.1.0
+ 14.2.0
$(Version)
..\..\MapControl.snk
true
diff --git a/MapControl/Shared/MapTileLayer.cs b/MapControl/Shared/MapTileLayer.cs
index d9f46acb..eb16b6aa 100644
--- a/MapControl/Shared/MapTileLayer.cs
+++ b/MapControl/Shared/MapTileLayer.cs
@@ -24,6 +24,11 @@ namespace MapControl
///
public partial class MapTileLayer : TilePyramidLayer
{
+ private const int TileSize = 256;
+
+ private static readonly Point MapTopLeft = new(-180d * MapProjection.Wgs84MeterPerDegree,
+ 180d * MapProjection.Wgs84MeterPerDegree);
+
public static readonly DependencyProperty MinZoomLevelProperty =
DependencyPropertyHelper.Register(nameof(MinZoomLevel), 0);
@@ -33,11 +38,6 @@ namespace MapControl
public static readonly DependencyProperty ZoomLevelOffsetProperty =
DependencyPropertyHelper.Register(nameof(ZoomLevelOffset), 0d);
- private const int TileSize = 256;
-
- private static readonly Point MapTopLeft = new(-180d * MapProjection.Wgs84MeterPerDegree,
- 180d * MapProjection.Wgs84MeterPerDegree);
-
///
/// A default MapTileLayer using OpenStreetMap data.
///
@@ -48,6 +48,11 @@ namespace MapControl
Description = "© [OpenStreetMap Contributors](http://www.openstreetmap.org/copyright)"
};
+ public MapTileLayer()
+ {
+ MapPanel.SetRenderTransform(this, new MatrixTransform());
+ }
+
public override IReadOnlyCollection SupportedCrsIds { get; } = [WebMercatorProjection.DefaultCrsId];
public TileMatrix TileMatrix { get; private set; }
diff --git a/MapControl/Shared/TileImageLoader.cs b/MapControl/Shared/TileImageLoader.cs
index fb105de9..9fcb6942 100644
--- a/MapControl/Shared/TileImageLoader.cs
+++ b/MapControl/Shared/TileImageLoader.cs
@@ -165,7 +165,7 @@ namespace MapControl
}
else if (uri.Scheme != "http" && uri.Scheme != "https" || string.IsNullOrEmpty(cacheName))
{
- await tile.LoadImageAsync(() => ImageLoader.LoadImageAsync(uri)).ConfigureAwait(false);
+ await tile.LoadImageAsync(() => tileSource.LoadImageAsync(uri)).ConfigureAwait(false);
}
else
{
@@ -173,7 +173,7 @@ namespace MapControl
if (buffer != null)
{
- await tile.LoadImageAsync(() => ImageLoader.LoadImageAsync(buffer)).ConfigureAwait(false);
+ await tile.LoadImageAsync(() => tileSource.LoadImageAsync(buffer)).ConfigureAwait(false);
}
}
}
diff --git a/MapControl/Shared/TilePyramidLayer.cs b/MapControl/Shared/TilePyramidLayer.cs
index 3bda6cf2..08bdfa98 100644
--- a/MapControl/Shared/TilePyramidLayer.cs
+++ b/MapControl/Shared/TilePyramidLayer.cs
@@ -69,8 +69,6 @@ namespace MapControl
updateTimer = new UpdateTimer { Interval = UpdateInterval };
updateTimer.Tick += (s, e) => UpdateTiles();
-
- MapPanel.SetRenderTransform(this, new MatrixTransform());
#if WPF
RenderOptions.SetEdgeMode(this, EdgeMode.Aliased);
#elif UWP || WINUI
diff --git a/MapControl/Shared/TileSource.cs b/MapControl/Shared/TileSource.cs
index 8d0cb03b..c1976025 100644
--- a/MapControl/Shared/TileSource.cs
+++ b/MapControl/Shared/TileSource.cs
@@ -1,4 +1,5 @@
using System;
+using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
#if WPF
@@ -14,7 +15,7 @@ using ImageSource = Avalonia.Media.IImage;
namespace MapControl
{
///
- /// Provides the download Uri or ImageSource of map tiles.
+ /// Provides the download Uri or ImageSource of map tiles. Used by TileImageLoader.
///
#if UWP || WINUI
[Windows.Foundation.Metadata.CreateFromString(MethodName = "Parse")]
@@ -24,15 +25,38 @@ namespace MapControl
public class TileSource
{
///
- /// Gets the image request Uri for the specified zoom level and tile indices.
- /// May return null when the image shall be loaded by the LoadImageAsync method.
+ /// Gets an image request Uri for the specified zoom level and tile indices.
+ /// May return null when the image shall be loaded by
+ /// the LoadImageAsync(zoomLevel, column, row) method.
///
- public virtual Uri GetUri(int zoomLevel, int column, int row) => null;
+ public virtual Uri GetUri(int zoomLevel, int column, int row)
+ {
+ return null;
+ }
///
/// Loads a tile image without an Uri.
///
- public virtual Task LoadImageAsync(int zoomLevel, int column, int row) => null;
+ public virtual Task LoadImageAsync(int zoomLevel, int column, int row)
+ {
+ return null;
+ }
+
+ ///
+ /// Loads a tile image from an Uri.
+ ///
+ public virtual Task LoadImageAsync(Uri uri)
+ {
+ return ImageLoader.LoadImageAsync(uri);
+ }
+
+ ///
+ /// Loads a tile image from an encoded frame buffer.
+ ///
+ public virtual Task LoadImageAsync(byte[] buffer)
+ {
+ return ImageLoader.LoadImageAsync(buffer);
+ }
///
/// Creates a TileSource instance from an Uri template string.
diff --git a/MapControl/Shared/WmtsTileMatrixLayer.cs b/MapControl/Shared/WmtsTileMatrixLayer.cs
index f1566d6c..9d2c8380 100644
--- a/MapControl/Shared/WmtsTileMatrixLayer.cs
+++ b/MapControl/Shared/WmtsTileMatrixLayer.cs
@@ -117,12 +117,14 @@ namespace MapControl
{
// Arrange tiles relative to XMin/YMin.
//
- var x = WmtsTileMatrix.TileWidth * (tile.X - TileMatrix.XMin);
- var y = WmtsTileMatrix.TileHeight * (tile.Y - TileMatrix.YMin);
+ var tileWidth = WmtsTileMatrix.TileWidth;
+ var tileHeight = WmtsTileMatrix.TileHeight;
+ var x = tileWidth * (tile.X - TileMatrix.XMin);
+ var y = tileHeight * (tile.Y - TileMatrix.YMin);
- tile.Image.Width = WmtsTileMatrix.TileWidth;
- tile.Image.Height = WmtsTileMatrix.TileHeight;
- tile.Image.Arrange(new Rect(x, y, WmtsTileMatrix.TileWidth, WmtsTileMatrix.TileHeight));
+ tile.Image.Width = tileWidth;
+ tile.Image.Height = tileHeight;
+ tile.Image.Arrange(new Rect(x, y, tileWidth, tileHeight));
}
return finalSize;