mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-06 23:15:14 +00:00
Updated MapsforgeTiles projects
This commit is contained in:
parent
105e812afa
commit
a9f0ccc78b
13 changed files with 196 additions and 138 deletions
31
MapsforgeTiles/Shared/MapsforgeTileSource.cs
Normal file
31
MapsforgeTiles/Shared/MapsforgeTileSource.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using System.Threading.Tasks;
|
||||
#if WPF
|
||||
using System.Windows.Media;
|
||||
#elif UWP
|
||||
using Windows.UI.Xaml.Media;
|
||||
#elif WINUI
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
#elif AVALONIA
|
||||
using ImageSource=Avalonia.Media.IImage;
|
||||
#endif
|
||||
|
||||
namespace MapControl.MapsforgeTiles
|
||||
{
|
||||
public partial class MapsforgeTileSource(string theme, int cacheCapacity = 200) : TileSource
|
||||
{
|
||||
private readonly TileRenderer renderer = new(theme, cacheCapacity);
|
||||
|
||||
public static void Initialize(string mapFilePath, float dpiScale)
|
||||
{
|
||||
TileRenderer.Initialize(mapFilePath, dpiScale);
|
||||
}
|
||||
|
||||
public override Task<ImageSource> LoadImageAsync(int zoomLevel, int column, int row)
|
||||
{
|
||||
var pixels = renderer.RenderTile(zoomLevel, column, row);
|
||||
ImageSource image = pixels != null ? CreateImage(pixels) : null;
|
||||
|
||||
return Task.FromResult(image);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue