mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
Version 4.2.0
This commit is contained in:
parent
9f8ef8acb0
commit
fd02476c6b
17 changed files with 174 additions and 141 deletions
|
|
@ -3,7 +3,16 @@
|
|||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Threading.Tasks;
|
||||
#if WINDOWS_UWP
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
#else
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
#endif
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
|
|
@ -85,6 +94,41 @@ namespace MapControl
|
|||
return getUri?.Invoke(x, y, zoomLevel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load a tile ImageSource asynchronously from GetUri(x, y, zoomLevel)
|
||||
/// </summary>
|
||||
public virtual async Task<ImageSource> LoadImageAsync(int x, int y, int zoomLevel)
|
||||
{
|
||||
ImageSource imageSource = null;
|
||||
|
||||
var uri = GetUri(x, y, zoomLevel);
|
||||
|
||||
if (uri != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!uri.IsAbsoluteUri || uri.Scheme == "file")
|
||||
{
|
||||
imageSource = await LoadLocalImageAsync(uri);
|
||||
}
|
||||
else if (uri.Scheme == "http")
|
||||
{
|
||||
imageSource = await LoadHttpImageAsync(uri);
|
||||
}
|
||||
else
|
||||
{
|
||||
imageSource = new BitmapImage(uri);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine("TileSource: {0}: {1}", uri, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
return imageSource;
|
||||
}
|
||||
|
||||
private Uri GetBasicUri(int x, int y, int zoomLevel)
|
||||
{
|
||||
return new Uri(uriFormat
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue