mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Version 4.10.0: Updated target framework versions. Cleanup of TypeConverters, ImageLoader, MBTileSource.
This commit is contained in:
parent
acf43d70ea
commit
1359cea83c
|
|
@ -28,6 +28,8 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
ImageSource imageSource = null;
|
ImageSource imageSource = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (!uri.IsAbsoluteUri || uri.Scheme == "file")
|
if (!uri.IsAbsoluteUri || uri.Scheme == "file")
|
||||||
{
|
{
|
||||||
imageSource = await LoadLocalImageAsync(uri);
|
imageSource = await LoadLocalImageAsync(uri);
|
||||||
|
|
@ -40,6 +42,11 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
imageSource = new BitmapImage(uri);
|
imageSource = new BitmapImage(uri);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.WriteLine("ImageLoader: {0}: {1}", uri, ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
return imageSource;
|
return imageSource;
|
||||||
}
|
}
|
||||||
|
|
@ -48,6 +55,8 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
ImageSource imageSource = null;
|
ImageSource imageSource = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
using (var response = await HttpClient.GetAsync(uri))
|
using (var response = await HttpClient.GetAsync(uri))
|
||||||
{
|
{
|
||||||
if (!response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
|
|
@ -58,9 +67,14 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
imageSource = await CreateImageSourceAsync(response.Content);
|
imageSource = await CreateImageSourceAsync(response.Content);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.WriteLine("ImageLoader: {0}: {1}", uri, ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
return imageSource;
|
return imageSource;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
// Licensed under the Microsoft Public License (Ms-PL)
|
// Licensed under the Microsoft Public License (Ms-PL)
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#if WINDOWS_UWP
|
#if WINDOWS_UWP
|
||||||
|
|
@ -112,20 +111,12 @@ namespace MapControl
|
||||||
public virtual async Task<ImageSource> LoadImageAsync(int x, int y, int zoomLevel)
|
public virtual async Task<ImageSource> LoadImageAsync(int x, int y, int zoomLevel)
|
||||||
{
|
{
|
||||||
ImageSource imageSource = null;
|
ImageSource imageSource = null;
|
||||||
|
|
||||||
var uri = GetUri(x, y, zoomLevel);
|
var uri = GetUri(x, y, zoomLevel);
|
||||||
|
|
||||||
if (uri != null)
|
if (uri != null)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
imageSource = await ImageLoader.LoadImageAsync(uri);
|
imageSource = await ImageLoader.LoadImageAsync(uri);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Debug.WriteLine("TileSource: {0}: {1}", uri, ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return imageSource;
|
return imageSource;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -124,15 +124,8 @@ namespace MapControl
|
||||||
uri += "&FORMAT=" + Format;
|
uri += "&FORMAT=" + Format;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
imageSource = await ImageLoader.LoadImageAsync(new Uri(uri.Replace(" ", "%20")));
|
imageSource = await ImageLoader.LoadImageAsync(new Uri(uri.Replace(" ", "%20")));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Debug.WriteLine("WmsImageLayer: {0}: {1}", uri, ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return imageSource;
|
return imageSource;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,9 @@ namespace MapControl
|
||||||
public static async Task<ImageSource> LoadLocalImageAsync(Uri uri)
|
public static async Task<ImageSource> LoadLocalImageAsync(Uri uri)
|
||||||
{
|
{
|
||||||
ImageSource imageSource = null;
|
ImageSource imageSource = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
var path = uri.IsAbsoluteUri ? uri.LocalPath : uri.OriginalString;
|
var path = uri.IsAbsoluteUri ? uri.LocalPath : uri.OriginalString;
|
||||||
|
|
||||||
if (File.Exists(path))
|
if (File.Exists(path))
|
||||||
|
|
@ -31,6 +34,11 @@ namespace MapControl
|
||||||
imageSource = await CreateImageSourceAsync(stream);
|
imageSource = await CreateImageSourceAsync(stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.WriteLine("ImageLoader: {0}: {1}", uri, ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
return imageSource;
|
return imageSource;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,12 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
public static partial class ImageLoader
|
public static partial class ImageLoader
|
||||||
{
|
{
|
||||||
public static Task<ImageSource> LoadLocalImageAsync(Uri uri)
|
public static ImageSource LoadLocalImage(Uri uri)
|
||||||
{
|
|
||||||
return Task.Run(() =>
|
|
||||||
{
|
{
|
||||||
ImageSource imageSource = null;
|
ImageSource imageSource = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
var path = uri.IsAbsoluteUri ? uri.LocalPath : uri.OriginalString;
|
var path = uri.IsAbsoluteUri ? uri.LocalPath : uri.OriginalString;
|
||||||
|
|
||||||
if (File.Exists(path))
|
if (File.Exists(path))
|
||||||
|
|
@ -31,9 +32,18 @@ namespace MapControl
|
||||||
imageSource = CreateImageSource(stream);
|
imageSource = CreateImageSource(stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.WriteLine("ImageLoader: {0}: {1}", uri, ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
return imageSource;
|
return imageSource;
|
||||||
});
|
}
|
||||||
|
|
||||||
|
public static Task<ImageSource> LoadLocalImageAsync(Uri uri)
|
||||||
|
{
|
||||||
|
return Task.Run(() => LoadLocalImage(uri));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<Tuple<MemoryStream, TimeSpan?>> LoadHttpStreamAsync(Uri uri)
|
public static async Task<Tuple<MemoryStream, TimeSpan?>> LoadHttpStreamAsync(Uri uri)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue