mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Version 4.2.0
This commit is contained in:
parent
9f8ef8acb0
commit
fd02476c6b
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2017 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2017 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("4.1.0")]
|
[assembly: AssemblyVersion("4.2.0")]
|
||||||
[assembly: AssemblyFileVersion("4.1.0")]
|
[assembly: AssemblyFileVersion("4.2.0")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2017 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2017 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("4.1.0")]
|
[assembly: AssemblyVersion("4.2.0")]
|
||||||
[assembly: AssemblyFileVersion("4.1.0")]
|
[assembly: AssemblyFileVersion("4.2.0")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2017 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2017 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("4.1.0")]
|
[assembly: AssemblyVersion("4.2.0")]
|
||||||
[assembly: AssemblyFileVersion("4.1.0")]
|
[assembly: AssemblyFileVersion("4.2.0")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2017 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2017 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("4.1.0")]
|
[assembly: AssemblyVersion("4.2.0")]
|
||||||
[assembly: AssemblyFileVersion("4.1.0")]
|
[assembly: AssemblyFileVersion("4.2.0")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,8 @@ namespace MapControl
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var document = await XmlDocument.LoadFromUriAsync(new Uri(imageryMetadataUrl + "?output=xml&key=" + ApiKey));
|
var uri = new Uri(imageryMetadataUrl + "?output=xml&key=" + ApiKey);
|
||||||
|
var document = await XmlDocument.LoadFromUriAsync(uri);
|
||||||
var imageryMetadata = document.DocumentElement.GetElementsByTagName("ImageryMetadata").OfType<XmlElement>().FirstOrDefault();
|
var imageryMetadata = document.DocumentElement.GetElementsByTagName("ImageryMetadata").OfType<XmlElement>().FirstOrDefault();
|
||||||
|
|
||||||
if (imageryMetadata != null)
|
if (imageryMetadata != null)
|
||||||
|
|
|
||||||
|
|
@ -271,29 +271,25 @@ namespace MapControl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var imageUpdated = false;
|
ImageSource imageSource = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
imageUpdated = UpdateImage(boundingBox);
|
imageSource = GetImage(boundingBox);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("MapImageLayer: " + ex.Message);
|
Debug.WriteLine("MapImageLayer: " + ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!imageUpdated)
|
UpdateImage(imageSource);
|
||||||
{
|
|
||||||
UpdateImage((BitmapSource)null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates an image request Uri or a BitmapSource for the specified image bounding box.
|
/// Returns an ImageSource for the specified bounding box.
|
||||||
/// Must either call UpdateImage(Uri) or UpdateImage(BitmapSource) or return false on failure.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected abstract bool UpdateImage(BoundingBox boundingBox);
|
protected abstract ImageSource GetImage(BoundingBox boundingBox);
|
||||||
|
|
||||||
private void SetTopImage(ImageSource imageSource)
|
private void SetTopImage(ImageSource imageSource)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,16 @@
|
||||||
// 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;
|
||||||
|
#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
|
namespace MapControl
|
||||||
{
|
{
|
||||||
|
|
@ -85,6 +94,41 @@ namespace MapControl
|
||||||
return getUri?.Invoke(x, y, zoomLevel);
|
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)
|
private Uri GetBasicUri(int x, int y, int zoomLevel)
|
||||||
{
|
{
|
||||||
return new Uri(uriFormat
|
return new Uri(uriFormat
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,13 @@ using System.Threading.Tasks;
|
||||||
#if WINDOWS_UWP
|
#if WINDOWS_UWP
|
||||||
using Windows.Data.Xml.Dom;
|
using Windows.Data.Xml.Dom;
|
||||||
using Windows.UI.Xaml;
|
using Windows.UI.Xaml;
|
||||||
|
using Windows.UI.Xaml.Media;
|
||||||
|
using Windows.UI.Xaml.Media.Imaging;
|
||||||
#else
|
#else
|
||||||
using System.Windows;
|
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace MapControl
|
namespace MapControl
|
||||||
|
|
@ -81,25 +85,25 @@ namespace MapControl
|
||||||
set { SetValue(TransparentProperty, value); }
|
set { SetValue(TransparentProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool UpdateImage(BoundingBox boundingBox)
|
protected override ImageSource GetImage(BoundingBox boundingBox)
|
||||||
{
|
{
|
||||||
if (ServerUri == null)
|
if (ServerUri == null)
|
||||||
{
|
{
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var projectionParameters = ParentMap.MapProjection.WmsQueryParameters(boundingBox, Version);
|
var projectionParameters = ParentMap.MapProjection.WmsQueryParameters(boundingBox, Version);
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(projectionParameters))
|
if (string.IsNullOrEmpty(projectionParameters))
|
||||||
{
|
{
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateImage(GetRequestUri("GetMap"
|
var uri = GetRequestUri("GetMap"
|
||||||
+ "&LAYERS=" + Layers + "&STYLES=" + Styles + "&FORMAT=" + Format
|
+ "&LAYERS=" + Layers + "&STYLES=" + Styles + "&FORMAT=" + Format
|
||||||
+ "&TRANSPARENT=" + (Transparent ? "TRUE" : "FALSE") + "&" + projectionParameters));
|
+ "&TRANSPARENT=" + (Transparent ? "TRUE" : "FALSE") + "&" + projectionParameters);
|
||||||
|
|
||||||
return true;
|
return new BitmapImage(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IList<string>> GetLayerNamesAsync()
|
public async Task<IList<string>> GetLayerNamesAsync()
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
// © 2017 Clemens Fischer
|
// © 2017 Clemens Fischer
|
||||||
// Licensed under the Microsoft Public License (Ms-PL)
|
// Licensed under the Microsoft Public License (Ms-PL)
|
||||||
|
|
||||||
using System;
|
|
||||||
using Windows.UI.Xaml;
|
using Windows.UI.Xaml;
|
||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
using Windows.UI.Xaml.Media;
|
using Windows.UI.Xaml.Media;
|
||||||
|
|
@ -12,11 +11,6 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
public partial class MapImageLayer
|
public partial class MapImageLayer
|
||||||
{
|
{
|
||||||
protected void UpdateImage(Uri uri)
|
|
||||||
{
|
|
||||||
UpdateImage(uri != null ? new BitmapImage(uri) : null);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void UpdateImage(ImageSource imageSource)
|
protected void UpdateImage(ImageSource imageSource)
|
||||||
{
|
{
|
||||||
SetTopImage(imageSource);
|
SetTopImage(imageSource);
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2017 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2017 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("4.1.0")]
|
[assembly: AssemblyVersion("4.2.0")]
|
||||||
[assembly: AssemblyFileVersion("4.1.0")]
|
[assembly: AssemblyFileVersion("4.2.0")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,9 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Windows.Storage;
|
||||||
using Windows.Storage.Streams;
|
using Windows.Storage.Streams;
|
||||||
using Windows.UI.Xaml.Media;
|
using Windows.UI.Xaml.Media;
|
||||||
using Windows.UI.Xaml.Media.Imaging;
|
using Windows.UI.Xaml.Media.Imaging;
|
||||||
|
|
@ -21,7 +23,7 @@ namespace MapControl
|
||||||
public static HttpClient HttpClient { get; set; } = new HttpClient();
|
public static HttpClient HttpClient { get; set; } = new HttpClient();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check HTTP response headers for tile unavailability, e.g. X-VE-Tile-Info=no-tile
|
/// Check HTTP response headers for tile availability, e.g. X-VE-Tile-Info=no-tile
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool TileAvailable(HttpResponseHeaderCollection responseHeaders)
|
public static bool TileAvailable(HttpResponseHeaderCollection responseHeaders)
|
||||||
{
|
{
|
||||||
|
|
@ -30,20 +32,27 @@ namespace MapControl
|
||||||
return !responseHeaders.TryGetValue("X-VE-Tile-Info", out tileInfo) || tileInfo != "no-tile";
|
return !responseHeaders.TryGetValue("X-VE-Tile-Info", out tileInfo) || tileInfo != "no-tile";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
protected async Task<ImageSource> LoadLocalImageAsync(Uri uri)
|
||||||
/// 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 path = uri.IsAbsoluteUri ? uri.LocalPath : uri.OriginalString;
|
||||||
|
|
||||||
var uri = GetUri(x, y, zoomLevel);
|
if (!await Task.Run(() => File.Exists(path)))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (uri != null)
|
var file = await StorageFile.GetFileFromPathAsync(path);
|
||||||
|
|
||||||
|
using (var stream = await file.OpenReadAsync())
|
||||||
{
|
{
|
||||||
try
|
var bitmapImage = new BitmapImage();
|
||||||
{
|
await bitmapImage.SetSourceAsync(stream);
|
||||||
if (uri.Scheme == "http")
|
|
||||||
|
return bitmapImage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async Task<ImageSource> LoadHttpImageAsync(Uri uri)
|
||||||
{
|
{
|
||||||
using (var response = await HttpClient.GetAsync(uri))
|
using (var response = await HttpClient.GetAsync(uri))
|
||||||
{
|
{
|
||||||
|
|
@ -61,23 +70,12 @@ namespace MapControl
|
||||||
var bitmapImage = new BitmapImage();
|
var bitmapImage = new BitmapImage();
|
||||||
await bitmapImage.SetSourceAsync(stream);
|
await bitmapImage.SetSourceAsync(stream);
|
||||||
|
|
||||||
imageSource = bitmapImage;
|
return bitmapImage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
imageSource = new BitmapImage(uri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Debug.WriteLine("TileSource: {0}: {1}", uri, ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return imageSource;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,6 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
public partial class MapImageLayer
|
public partial class MapImageLayer
|
||||||
{
|
{
|
||||||
protected void UpdateImage(Uri uri)
|
|
||||||
{
|
|
||||||
UpdateImage(uri != null
|
|
||||||
? BitmapFrame.Create(uri, BitmapCreateOptions.IgnoreImageCache, BitmapCacheOption.OnDemand)
|
|
||||||
: null);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void UpdateImage(ImageSource imageSource)
|
protected void UpdateImage(ImageSource imageSource)
|
||||||
{
|
{
|
||||||
SetTopImage(imageSource);
|
SetTopImage(imageSource);
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ using System.Windows;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2017 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2017 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("4.1.0")]
|
[assembly: AssemblyVersion("4.2.0")]
|
||||||
[assembly: AssemblyFileVersion("4.1.0")]
|
[assembly: AssemblyFileVersion("4.2.0")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ namespace MapControl
|
||||||
public static HttpClient HttpClient { get; set; } = new HttpClient();
|
public static HttpClient HttpClient { get; set; } = new HttpClient();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check HTTP response headers for tile unavailability, e.g. X-VE-Tile-Info=no-tile
|
/// Check HTTP response headers for tile availability, e.g. X-VE-Tile-Info=no-tile
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool TileAvailable(HttpResponseHeaders responseHeaders)
|
public static bool TileAvailable(HttpResponseHeaders responseHeaders)
|
||||||
{
|
{
|
||||||
|
|
@ -32,20 +32,25 @@ namespace MapControl
|
||||||
return !responseHeaders.TryGetValues("X-VE-Tile-Info", out tileInfo) || !tileInfo.Contains("no-tile");
|
return !responseHeaders.TryGetValues("X-VE-Tile-Info", out tileInfo) || !tileInfo.Contains("no-tile");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
protected Task<ImageSource> LoadLocalImageAsync(Uri uri)
|
||||||
/// 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;
|
return Task.Run(() =>
|
||||||
|
{
|
||||||
|
var path = uri.IsAbsoluteUri ? uri.LocalPath : uri.OriginalString;
|
||||||
|
|
||||||
var uri = GetUri(x, y, zoomLevel);
|
if (File.Exists(path))
|
||||||
|
{
|
||||||
|
using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read))
|
||||||
|
{
|
||||||
|
return (ImageSource)BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (uri != null)
|
return null;
|
||||||
{
|
});
|
||||||
try
|
}
|
||||||
{
|
|
||||||
if (uri.Scheme == "http")
|
protected async Task<ImageSource> LoadHttpImageAsync(Uri uri)
|
||||||
{
|
{
|
||||||
using (var response = await HttpClient.GetAsync(uri))
|
using (var response = await HttpClient.GetAsync(uri))
|
||||||
{
|
{
|
||||||
|
|
@ -60,23 +65,12 @@ namespace MapControl
|
||||||
await response.Content.CopyToAsync(stream);
|
await response.Content.CopyToAsync(stream);
|
||||||
stream.Seek(0, SeekOrigin.Begin);
|
stream.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
imageSource = await Task.Run(() => BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad));
|
return await Task.Run(() => BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
imageSource = BitmapFrame.Create(uri, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Debug.WriteLine("TileSource: {0}: {1}", uri, ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return imageSource;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ namespace ViewModel
|
||||||
new MapTileLayer
|
new MapTileLayer
|
||||||
{
|
{
|
||||||
SourceName = "Stamen Terrain",
|
SourceName = "Stamen Terrain",
|
||||||
Description = "Map tiles by [Stamen Design](http://stamen.com/), under [CC BY 3.0](http://creativecommons.org/licenses/by/3.0). Data by OpenStreetMap, under [ODbL](http://www.openstreetmap.org/copyright)",
|
Description = "Map tiles by [Stamen Design](http://stamen.com/), under [CC BY 3.0](http://creativecommons.org/licenses/by/3.0)\nData by [OpenStreetMap](http://openstreetmap.org/), under [ODbL](http://www.openstreetmap.org/copyright)",
|
||||||
TileSource = new TileSource { UriFormat = "http://tile.stamen.com/terrain/{z}/{x}/{y}.png" },
|
TileSource = new TileSource { UriFormat = "http://tile.stamen.com/terrain/{z}/{x}/{y}.png" },
|
||||||
MaxZoomLevel = 17
|
MaxZoomLevel = 17
|
||||||
}
|
}
|
||||||
|
|
@ -48,7 +48,7 @@ namespace ViewModel
|
||||||
new MapTileLayer
|
new MapTileLayer
|
||||||
{
|
{
|
||||||
SourceName = "Stamen Toner Light",
|
SourceName = "Stamen Toner Light",
|
||||||
Description = "Map tiles by [Stamen Design](http://stamen.com/), under [CC BY 3.0](http://creativecommons.org/licenses/by/3.0). Data by OpenStreetMap, under [ODbL](http://www.openstreetmap.org/copyright)",
|
Description = "Map tiles by [Stamen Design](http://stamen.com/), under [CC BY 3.0](http://creativecommons.org/licenses/by/3.0)\nData by [OpenStreetMap](http://openstreetmap.org/), under [ODbL](http://www.openstreetmap.org/copyright)",
|
||||||
TileSource = new TileSource { UriFormat = "http://tile.stamen.com/toner-lite/{z}/{x}/{y}.png" },
|
TileSource = new TileSource { UriFormat = "http://tile.stamen.com/toner-lite/{z}/{x}/{y}.png" },
|
||||||
MaxZoomLevel = 18
|
MaxZoomLevel = 18
|
||||||
}
|
}
|
||||||
|
|
@ -68,9 +68,8 @@ namespace ViewModel
|
||||||
new BingMapsTileLayer
|
new BingMapsTileLayer
|
||||||
{
|
{
|
||||||
SourceName = "Bing Maps Road",
|
SourceName = "Bing Maps Road",
|
||||||
Description = "© [Microsoft Corporation](http://www.bing.com/maps/)",
|
Description = "© [Microsoft](http://www.bing.com/maps/)",
|
||||||
Mode = BingMapsTileLayer.MapMode.Road,
|
Mode = BingMapsTileLayer.MapMode.Road
|
||||||
MaxZoomLevel = 19
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -78,9 +77,8 @@ namespace ViewModel
|
||||||
new BingMapsTileLayer
|
new BingMapsTileLayer
|
||||||
{
|
{
|
||||||
SourceName = "Bing Maps Aerial",
|
SourceName = "Bing Maps Aerial",
|
||||||
Description = "© [Microsoft Corporation](http://www.bing.com/maps/)",
|
Description = "© [Microsoft](http://www.bing.com/maps/)",
|
||||||
Mode = BingMapsTileLayer.MapMode.Aerial,
|
Mode = BingMapsTileLayer.MapMode.Aerial,
|
||||||
MaxZoomLevel = 19,
|
|
||||||
MapForeground = new SolidColorBrush(Colors.White),
|
MapForeground = new SolidColorBrush(Colors.White),
|
||||||
MapBackground = new SolidColorBrush(Colors.Black)
|
MapBackground = new SolidColorBrush(Colors.Black)
|
||||||
}
|
}
|
||||||
|
|
@ -90,9 +88,8 @@ namespace ViewModel
|
||||||
new BingMapsTileLayer
|
new BingMapsTileLayer
|
||||||
{
|
{
|
||||||
SourceName = "Bing Maps Hybrid",
|
SourceName = "Bing Maps Hybrid",
|
||||||
Description = "© [Microsoft Corporation](http://www.bing.com/maps/)",
|
Description = "© [Microsoft](http://www.bing.com/maps/)",
|
||||||
Mode = BingMapsTileLayer.MapMode.AerialWithLabels,
|
Mode = BingMapsTileLayer.MapMode.AerialWithLabels,
|
||||||
MaxZoomLevel = 19,
|
|
||||||
MapForeground = new SolidColorBrush(Colors.White),
|
MapForeground = new SolidColorBrush(Colors.White),
|
||||||
MapBackground = new SolidColorBrush(Colors.Black)
|
MapBackground = new SolidColorBrush(Colors.Black)
|
||||||
}
|
}
|
||||||
|
|
@ -101,20 +98,28 @@ namespace ViewModel
|
||||||
"OpenStreetMap WMS",
|
"OpenStreetMap WMS",
|
||||||
new WmsImageLayer
|
new WmsImageLayer
|
||||||
{
|
{
|
||||||
Description = "OpenStreetMap WMS",
|
Description = "© [terrestris GmbH & Co. KG](http://ows.terrestris.de/)\nData © [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)",
|
||||||
ServerUri = new Uri("http://ows.terrestris.de/osm/service"),
|
ServerUri = new Uri("http://ows.terrestris.de/osm/service"),
|
||||||
Layers = "OSM-WMS",
|
Layers = "OSM-WMS"
|
||||||
MapBackground = new SolidColorBrush(Colors.LightGray)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"OpenStreetMap TOPO WMS",
|
"OpenStreetMap TOPO WMS",
|
||||||
new WmsImageLayer
|
new WmsImageLayer
|
||||||
{
|
{
|
||||||
Description = "OpenStreetMap TOPO WMS",
|
Description = "© [terrestris GmbH & Co. KG](http://ows.terrestris.de/)\nData © [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)",
|
||||||
ServerUri = new Uri("http://ows.terrestris.de/osm/service"),
|
ServerUri = new Uri("http://ows.terrestris.de/osm/service"),
|
||||||
Layers = "TOPO-OSM-WMS",
|
Layers = "TOPO-OSM-WMS"
|
||||||
MapBackground = new SolidColorBrush(Colors.LightGray)
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"SevenCs ChartServer",
|
||||||
|
new WmsImageLayer
|
||||||
|
{
|
||||||
|
Description = "© [SevenCs GmbH](http://www.sevencs.com)",
|
||||||
|
ServerUri = new Uri("http://chartserver4.sevencs.com:8080"),
|
||||||
|
Layers = "ENC",
|
||||||
|
MaxBoundingBoxWidth = 360
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -149,7 +154,8 @@ namespace ViewModel
|
||||||
"Stamen Terrain",
|
"Stamen Terrain",
|
||||||
"Stamen Toner Light",
|
"Stamen Toner Light",
|
||||||
"OpenStreetMap WMS",
|
"OpenStreetMap WMS",
|
||||||
"OpenStreetMap TOPO WMS"
|
"OpenStreetMap TOPO WMS",
|
||||||
|
"SevenCs ChartServer"
|
||||||
};
|
};
|
||||||
|
|
||||||
public MapLayers()
|
public MapLayers()
|
||||||
|
|
@ -161,9 +167,12 @@ namespace ViewModel
|
||||||
// A Bing Maps API Key (see http://msdn.microsoft.com/en-us/library/ff428642.aspx) is required
|
// A Bing Maps API Key (see http://msdn.microsoft.com/en-us/library/ff428642.aspx) is required
|
||||||
// for using these layers and must be assigned to the static BingMapsTileLayer.ApiKey property.
|
// for using these layers and must be assigned to the static BingMapsTileLayer.ApiKey property.
|
||||||
|
|
||||||
//MapLayerNames.Add("Bing Maps Road");
|
if (!string.IsNullOrEmpty(BingMapsTileLayer.ApiKey))
|
||||||
//MapLayerNames.Add("Bing Maps Aerial");
|
{
|
||||||
//MapLayerNames.Add("Bing Maps Aerial with Labels");
|
MapLayerNames.Add("Bing Maps Road");
|
||||||
|
MapLayerNames.Add("Bing Maps Aerial");
|
||||||
|
MapLayerNames.Add("Bing Maps Aerial with Labels");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCopyright("© 2017 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2017 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: AssemblyVersion("4.1.0")]
|
[assembly: AssemblyVersion("4.2.0")]
|
||||||
[assembly: AssemblyFileVersion("4.1.0")]
|
[assembly: AssemblyFileVersion("4.2.0")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyCompany("Clemens Fischer")]
|
[assembly: AssemblyCompany("Clemens Fischer")]
|
||||||
[assembly: AssemblyCopyright("© 2017 Clemens Fischer")]
|
[assembly: AssemblyCopyright("© 2017 Clemens Fischer")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyVersion("4.1.0")]
|
[assembly: AssemblyVersion("4.2.0")]
|
||||||
[assembly: AssemblyFileVersion("4.1.0")]
|
[assembly: AssemblyFileVersion("4.2.0")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue