mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
TileSource.GetUri/LoadImageAsync argument order
This commit is contained in:
parent
3d6fc375b2
commit
d6faf252ee
|
|
@ -5,9 +5,9 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
public class BoundingBoxTileSource : TileSource
|
public class BoundingBoxTileSource : TileSource
|
||||||
{
|
{
|
||||||
public override Uri GetUri(int column, int row, int zoomLevel)
|
public override Uri GetUri(int zoomLevel, int column, int row)
|
||||||
{
|
{
|
||||||
GetTileBounds(column, row, zoomLevel, out double west, out double south, out double east, out double north);
|
GetTileBounds(zoomLevel, column, row, out double west, out double south, out double east, out double north);
|
||||||
|
|
||||||
return GetUri(west, south, east, north);
|
return GetUri(west, south, east, north);
|
||||||
}
|
}
|
||||||
|
|
@ -33,9 +33,9 @@ namespace MapControl
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the bounding box in meters of a standard Web Mercator tile,
|
/// Gets the bounding box in meters of a standard Web Mercator tile,
|
||||||
/// specified by grid column and row indices and zoom level.
|
/// specified by zoom level and grid column and row indices.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void GetTileBounds(int column, int row, int zoomLevel,
|
public static void GetTileBounds(int zoomLevel, int column, int row,
|
||||||
out double west, out double south, out double east, out double north)
|
out double west, out double south, out double east, out double north)
|
||||||
{
|
{
|
||||||
var tileSize = 360d / (1 << zoomLevel); // tile size in degrees
|
var tileSize = 360d / (1 << zoomLevel); // tile size in degrees
|
||||||
|
|
|
||||||
|
|
@ -150,15 +150,15 @@ namespace MapControl
|
||||||
private static async Task LoadTileImage(Tile tile, TileSource tileSource, string cacheName)
|
private static async Task LoadTileImage(Tile tile, TileSource tileSource, string cacheName)
|
||||||
{
|
{
|
||||||
// Pass tileSource.LoadImageAsync calls to platform-specific method
|
// Pass tileSource.LoadImageAsync calls to platform-specific method
|
||||||
// LoadTileImage(Tile, Func<Task<ImageSource>>) for execution on the UI thread in WinUI and UWP.
|
// tile.LoadImageAsync(Func<Task<ImageSource>>) for execution on the UI thread in WinUI and UWP.
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(cacheName))
|
if (string.IsNullOrEmpty(cacheName))
|
||||||
{
|
{
|
||||||
await tile.LoadImageAsync(() => tileSource.LoadImageAsync(tile.Column, tile.Row, tile.ZoomLevel)).ConfigureAwait(false);
|
await tile.LoadImageAsync(() => tileSource.LoadImageAsync(tile.ZoomLevel, tile.Column, tile.Row)).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var uri = tileSource.GetUri(tile.Column, tile.Row, tile.ZoomLevel);
|
var uri = tileSource.GetUri(tile.ZoomLevel, tile.Column, tile.Row);
|
||||||
|
|
||||||
if (uri != null)
|
if (uri != null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -48,16 +48,16 @@ namespace MapControl
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the image Uri for the specified tile indices and zoom level.
|
/// Gets the image Uri for the specified tile indices and zoom level.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual Uri GetUri(int column, int row, int zoomLevel)
|
public virtual Uri GetUri(int zoomLevel, int column, int row)
|
||||||
{
|
{
|
||||||
Uri uri = null;
|
Uri uri = null;
|
||||||
|
|
||||||
if (UriTemplate != null)
|
if (UriTemplate != null)
|
||||||
{
|
{
|
||||||
var uriString = UriTemplate
|
var uriString = UriTemplate
|
||||||
|
.Replace("{z}", zoomLevel.ToString())
|
||||||
.Replace("{x}", column.ToString())
|
.Replace("{x}", column.ToString())
|
||||||
.Replace("{y}", row.ToString())
|
.Replace("{y}", row.ToString());
|
||||||
.Replace("{z}", zoomLevel.ToString());
|
|
||||||
|
|
||||||
if (Subdomains != null && Subdomains.Length > 0)
|
if (Subdomains != null && Subdomains.Length > 0)
|
||||||
{
|
{
|
||||||
|
|
@ -71,12 +71,12 @@ namespace MapControl
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads a tile ImageSource asynchronously from GetUri(column, row, zoomLevel).
|
/// Loads a tile ImageSource asynchronously from GetUri(zoomLevel, column, row).
|
||||||
/// This method is called by TileImageLoader when caching is disabled.
|
/// This method is called by TileImageLoader when caching is disabled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual Task<ImageSource> LoadImageAsync(int column, int row, int zoomLevel)
|
public virtual Task<ImageSource> LoadImageAsync(int zoomLevel, int column, int row)
|
||||||
{
|
{
|
||||||
var uri = GetUri(column, row, zoomLevel);
|
var uri = GetUri(zoomLevel, column, row);
|
||||||
|
|
||||||
return uri != null ? ImageLoader.LoadImageAsync(uri) : Task.FromResult((ImageSource)null);
|
return uri != null ? ImageLoader.LoadImageAsync(uri) : Task.FromResult((ImageSource)null);
|
||||||
}
|
}
|
||||||
|
|
@ -106,9 +106,9 @@ namespace MapControl
|
||||||
|
|
||||||
public class TmsTileSource : TileSource
|
public class TmsTileSource : TileSource
|
||||||
{
|
{
|
||||||
public override Uri GetUri(int column, int row, int zoomLevel)
|
public override Uri GetUri(int zoomLevel, int column, int row)
|
||||||
{
|
{
|
||||||
return base.GetUri(column, (1 << zoomLevel) - 1 - row, zoomLevel);
|
return base.GetUri(zoomLevel, column, (1 << zoomLevel) - 1 - row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
var tcs = new TaskCompletionSource<object>();
|
var tcs = new TaskCompletionSource<object>();
|
||||||
|
|
||||||
async void LoadImage()
|
async void LoadAndSetImageSource()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -51,9 +51,9 @@ namespace MapControl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if UWP
|
#if UWP
|
||||||
if (!await Image.Dispatcher.TryRunAsync(CoreDispatcherPriority.Low, LoadImage))
|
if (!await Image.Dispatcher.TryRunAsync(CoreDispatcherPriority.Low, LoadAndSetImageSource))
|
||||||
#else
|
#else
|
||||||
if (!Image.DispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, LoadImage))
|
if (!Image.DispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, LoadAndSetImageSource))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
tcs.TrySetCanceled();
|
tcs.TrySetCanceled();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue