2025-02-27 18:46:32 +01:00
|
|
|
|
using System;
|
2017-10-08 17:35:07 +02:00
|
|
|
|
using System.Threading.Tasks;
|
2024-05-22 11:25:32 +02:00
|
|
|
|
#if WPF
|
|
|
|
|
|
using System.Windows.Media;
|
2021-11-17 23:17:11 +01:00
|
|
|
|
#elif UWP
|
2017-10-08 17:35:07 +02:00
|
|
|
|
using Windows.UI.Xaml.Media;
|
2024-05-22 11:25:32 +02:00
|
|
|
|
#elif WINUI
|
|
|
|
|
|
using Microsoft.UI.Xaml.Media;
|
2025-11-13 13:36:28 +01:00
|
|
|
|
#elif AVALONIA
|
|
|
|
|
|
using ImageSource = Avalonia.Media.IImage;
|
2017-10-08 17:35:07 +02:00
|
|
|
|
#endif
|
2012-04-25 22:02:53 +02:00
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
2012-05-04 12:52:20 +02:00
|
|
|
|
/// <summary>
|
2025-11-14 15:02:48 +01:00
|
|
|
|
/// Provides the download Uri or ImageSource of map tiles. Used by TileImageLoader.
|
2012-05-04 12:52:20 +02:00
|
|
|
|
/// </summary>
|
2024-05-22 11:25:32 +02:00
|
|
|
|
#if UWP || WINUI
|
2024-04-11 15:41:05 +02:00
|
|
|
|
[Windows.Foundation.Metadata.CreateFromString(MethodName = "Parse")]
|
2024-04-11 14:57:54 +02:00
|
|
|
|
#else
|
2021-06-14 21:41:37 +02:00
|
|
|
|
[System.ComponentModel.TypeConverter(typeof(TileSourceConverter))]
|
2018-08-08 23:31:52 +02:00
|
|
|
|
#endif
|
2025-11-13 17:06:33 +01:00
|
|
|
|
public class TileSource
|
2025-11-13 15:32:01 +01:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
2025-11-14 15:02:48 +01:00
|
|
|
|
/// 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.
|
2025-11-13 15:32:01 +01:00
|
|
|
|
/// </summary>
|
2025-11-14 15:02:48 +01:00
|
|
|
|
public virtual Uri GetUri(int zoomLevel, int column, int row)
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2025-11-13 15:32:01 +01:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-11-13 17:06:33 +01:00
|
|
|
|
/// Loads a tile image without an Uri.
|
2025-11-13 15:32:01 +01:00
|
|
|
|
/// </summary>
|
2025-11-14 15:02:48 +01:00
|
|
|
|
public virtual Task<ImageSource> LoadImageAsync(int zoomLevel, int column, int row)
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Loads a tile image from an Uri.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual Task<ImageSource> LoadImageAsync(Uri uri)
|
|
|
|
|
|
{
|
|
|
|
|
|
return ImageLoader.LoadImageAsync(uri);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Loads a tile image from an encoded frame buffer.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual Task<ImageSource> LoadImageAsync(byte[] buffer)
|
|
|
|
|
|
{
|
|
|
|
|
|
return ImageLoader.LoadImageAsync(buffer);
|
|
|
|
|
|
}
|
2025-11-13 15:32:01 +01:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Creates a TileSource instance from an Uri template string.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static TileSource Parse(string uriTemplate)
|
|
|
|
|
|
{
|
2025-12-02 16:41:20 +01:00
|
|
|
|
return new UriTileSource { UriTemplate = uriTemplate };
|
2013-05-07 18:12:25 +02:00
|
|
|
|
}
|
2020-10-23 23:35:48 +02:00
|
|
|
|
}
|
2012-04-25 22:02:53 +02:00
|
|
|
|
}
|