diff --git a/Caching/FileDbCache.UWP/Properties/AssemblyInfo.cs b/Caching/FileDbCache.UWP/Properties/AssemblyInfo.cs index 87c45105..35f703e9 100644 --- a/Caching/FileDbCache.UWP/Properties/AssemblyInfo.cs +++ b/Caching/FileDbCache.UWP/Properties/AssemblyInfo.cs @@ -1,7 +1,7 @@ using System.Reflection; using System.Runtime.InteropServices; -[assembly: AssemblyTitle("XAML Map Control FileDbCache for UWP")] +[assembly: AssemblyTitle("XAML Map Control FileDbCache (UWP)")] [assembly: AssemblyDescription("IImageCache implementation based on EzTools FileDb")] [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] diff --git a/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs b/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs index 18a184ab..e79c9e40 100644 --- a/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs +++ b/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs @@ -1,7 +1,7 @@ using System.Reflection; using System.Runtime.InteropServices; -[assembly: AssemblyTitle("XAML Map Control FileDbCache for WPF")] +[assembly: AssemblyTitle("XAML Map Control FileDbCache (WPF)")] [assembly: AssemblyDescription("ObjectCache implementation based on EzTools FileDb")] [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] diff --git a/MBTiles/Shared/MBTileLayer.cs b/MBTiles/Shared/MBTileLayer.cs new file mode 100644 index 00000000..133f2315 --- /dev/null +++ b/MBTiles/Shared/MBTileLayer.cs @@ -0,0 +1,95 @@ +#if WINDOWS_UWP +using Windows.UI.Xaml; +#else +using System.Windows; +#endif + +namespace MapControl +{ + public class MBTileLayer : MapTileLayer + { + public static readonly DependencyProperty FileProperty = DependencyProperty.Register( + nameof(File), typeof(string), typeof(MBTileLayer), + new PropertyMetadata(null, (o, e) => ((MBTileLayer)o).FilePropertyChanged((string)e.NewValue))); + + public MBTileLayer() + : this(new TileImageLoader()) + { + } + + public MBTileLayer(ITileImageLoader tileImageLoader) + : base(tileImageLoader) + { + } + + public string File + { + get { return (string)GetValue(FileProperty); } + set { SetValue(FileProperty, value); } + } + + private void FilePropertyChanged(string file) + { + MBTileSource ts; + + if (file != null) + { + ts = new MBTileSource(file); + + if (ts.Metadata.ContainsKey("name")) + { + SourceName = ts.Metadata["name"]; + } + + if (ts.Metadata.ContainsKey("description")) + { + Description = ts.Metadata["description"]; + } + + if (ts.Metadata.ContainsKey("minzoom")) + { + int minZoom; + if (int.TryParse(ts.Metadata["minzoom"], out minZoom)) + { + MinZoomLevel = minZoom; + } + } + + if (ts.Metadata.ContainsKey("maxzoom")) + { + int maxZoom; + if (int.TryParse(ts.Metadata["maxzoom"], out maxZoom)) + { + MaxZoomLevel = maxZoom; + } + } + + TileSource = ts; + } + else if ((ts = TileSource as MBTileSource) != null) + { + ClearValue(TileSourceProperty); + + if (ts.Metadata.ContainsKey("name")) + { + ClearValue(SourceNameProperty); + } + + if (ts.Metadata.ContainsKey("description")) + { + ClearValue(DescriptionProperty); + } + + if (ts.Metadata.ContainsKey("minzoom")) + { + ClearValue(MinZoomLevelProperty); + } + + if (ts.Metadata.ContainsKey("maxzoom")) + { + ClearValue(MaxZoomLevelProperty); + } + } + } + } +} diff --git a/MBTiles/UWP/MBTileSource.UWP.cs b/MBTiles/UWP/MBTileSource.UWP.cs new file mode 100644 index 00000000..700c3102 --- /dev/null +++ b/MBTiles/UWP/MBTileSource.UWP.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.InteropServices.WindowsRuntime; +using System.Threading.Tasks; +using Microsoft.Data.Sqlite; +using Windows.Storage.Streams; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Media.Imaging; + +namespace MapControl +{ + public class MBTileSource : TileSource, IDisposable + { + private readonly SqliteConnection connection; + + public IDictionary Metadata { get; } = new Dictionary(); + + public MBTileSource(string file) + { + connection = new SqliteConnection("Data Source=" + file); + connection.Open(); + + using (var command = new SqliteCommand("select * from metadata", connection)) + { + var reader = command.ExecuteReader(); + + while (reader.Read()) + { + Metadata[(string)reader["name"]] = (string)reader["value"]; + } + } + } + + public override async Task LoadImageAsync(int x, int y, int zoomLevel) + { + ImageSource imageSource = null; + + try + { + using (var command = new SqliteCommand("select tile_data from tiles where zoom_level=@z and tile_column=@x and tile_row=@y", connection)) + { + command.Parameters.AddWithValue("@z", zoomLevel); + command.Parameters.AddWithValue("@x", x); + command.Parameters.AddWithValue("@y", (1 << zoomLevel) - y - 1); + + var buffer = await command.ExecuteScalarAsync() as byte[]; + + if (buffer != null) + { + using (var stream = new InMemoryRandomAccessStream()) + { + await stream.WriteAsync(buffer.AsBuffer()); + stream.Seek(0); + + var bitmapImage = new BitmapImage(); + await bitmapImage.SetSourceAsync(stream); + + imageSource = bitmapImage; + } + } + } + } + catch (Exception ex) + { + Debug.WriteLine("MBTileSource: {0}/{1}/{2}: {3}", zoomLevel, x, y, ex.Message); + } + + return imageSource; + } + + public void Dispose() + { + Dispose(true); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing && connection != null) + { + connection.Close(); + } + } + } +} diff --git a/MBTiles/UWP/MBTiles.UWP.csproj b/MBTiles/UWP/MBTiles.UWP.csproj new file mode 100644 index 00000000..1ba0bb81 --- /dev/null +++ b/MBTiles/UWP/MBTiles.UWP.csproj @@ -0,0 +1,68 @@ + + + + + Debug + AnyCPU + {46D812C6-5354-46A6-8604-D4497E17E2A2} + Library + Properties + MBTiles + MBTiles.UWP + en-US + UAP + 10.0.14393.0 + 10.0.14393.0 + 14 + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + AnyCPU + true + full + false + ..\bin\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + prompt + 4 + + + AnyCPU + pdbonly + true + ..\bin\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + prompt + 4 + + + + + + + + MBTileLayer.cs + + + + + + + + {951bc5d2-d653-42d9-9a91-21dc50de0182} + MapControl.UWP + + + + 14.0 + + + + \ No newline at end of file diff --git a/MBTiles/UWP/Properties/AssemblyInfo.cs b/MBTiles/UWP/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..4f39d0aa --- /dev/null +++ b/MBTiles/UWP/Properties/AssemblyInfo.cs @@ -0,0 +1,14 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("XAML Map Control MBTiles Support (UWP)")] +[assembly: AssemblyDescription("MBTiles Support Library for XAML Map Control")] +[assembly: AssemblyProduct("XAML Map Control")] +[assembly: AssemblyCompany("Clemens Fischer")] +[assembly: AssemblyCopyright("© 2017 Clemens Fischer")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyVersion("4.1.0")] +[assembly: AssemblyFileVersion("4.1.0")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] diff --git a/MBTiles/UWP/Properties/MBTiles.UWP.rd.xml b/MBTiles/UWP/Properties/MBTiles.UWP.rd.xml new file mode 100644 index 00000000..8e1f888d --- /dev/null +++ b/MBTiles/UWP/Properties/MBTiles.UWP.rd.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/MBTiles/UWP/project.json b/MBTiles/UWP/project.json new file mode 100644 index 00000000..d4e8b41c --- /dev/null +++ b/MBTiles/UWP/project.json @@ -0,0 +1,17 @@ +{ + "dependencies": { + "Microsoft.Data.Sqlite": "1.1.1", + "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2" + }, + "frameworks": { + "uap10.0.14393": {} + }, + "runtimes": { + "win10-arm": {}, + "win10-arm-aot": {}, + "win10-x86": {}, + "win10-x86-aot": {}, + "win10-x64": {}, + "win10-x64-aot": {} + } +} \ No newline at end of file diff --git a/MBTiles/WPF/MBTileSource.WPF.cs b/MBTiles/WPF/MBTileSource.WPF.cs new file mode 100644 index 00000000..67853e4b --- /dev/null +++ b/MBTiles/WPF/MBTileSource.WPF.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Threading.Tasks; +using System.Data.SQLite; +using System.Windows.Media; +using System.Windows.Media.Imaging; + +namespace MapControl +{ + public class MBTileSource : TileSource, IDisposable + { + private readonly SQLiteConnection connection; + + public IDictionary Metadata { get; } = new Dictionary(); + + public MBTileSource(string file) + { + connection = new SQLiteConnection("Data Source=" + file + ";Version=3;"); + connection.Open(); + + using (var command = new SQLiteCommand("select * from metadata", connection)) + { + var reader = command.ExecuteReader(); + + while (reader.Read()) + { + Metadata[(string)reader["name"]] = (string)reader["value"]; + } + } + } + + public override async Task LoadImageAsync(int x, int y, int zoomLevel) + { + ImageSource imageSource = null; + + try + { + using (var command = new SQLiteCommand("select tile_data from tiles where zoom_level=@z and tile_column=@x and tile_row=@y", connection)) + { + command.Parameters.AddWithValue("@z", zoomLevel); + command.Parameters.AddWithValue("@x", x); + command.Parameters.AddWithValue("@y", (1 << zoomLevel) - y - 1); + + var buffer = await command.ExecuteScalarAsync() as byte[]; + + if (buffer != null) + { + imageSource = await Task.Run(() => + { + using (var stream = new MemoryStream(buffer)) + { + return BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad); + } + }); + } + } + } + catch (Exception ex) + { + Debug.WriteLine("MBTileSource: {0}/{1}/{2}: {3}", zoomLevel, x, y, ex.Message); + } + + return imageSource; + } + + public void Dispose() + { + Dispose(true); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing && connection != null) + { + connection.Close(); + } + } + } +} diff --git a/MBTiles/WPF/MBTiles.WPF.csproj b/MBTiles/WPF/MBTiles.WPF.csproj new file mode 100644 index 00000000..aa57db56 --- /dev/null +++ b/MBTiles/WPF/MBTiles.WPF.csproj @@ -0,0 +1,71 @@ + + + + + Debug + AnyCPU + {38B18AB6-6E70-4696-8FB4-E8C8E12BF50C} + Library + Properties + MapControl + MBTiles.WPF + v4.5 + 512 + + + + + + true + full + false + ..\bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + none + true + ..\bin\Release\ + TRACE + prompt + 4 + + + + + + + + + ..\..\packages\System.Data.SQLite.Core.1.0.105.2\lib\net45\System.Data.SQLite.dll + + + + + + + MBTileLayer.cs + + + + + + + {a204a102-c745-4d65-aec8-7b96faedef2d} + MapControl.WPF + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + \ No newline at end of file diff --git a/MBTiles/WPF/Properties/AssemblyInfo.cs b/MBTiles/WPF/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..6bfb8f70 --- /dev/null +++ b/MBTiles/WPF/Properties/AssemblyInfo.cs @@ -0,0 +1,14 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("XAML Map Control MBTiles Support (WPF)")] +[assembly: AssemblyDescription("MBTiles Support Library for XAML Map Control")] +[assembly: AssemblyProduct("XAML Map Control")] +[assembly: AssemblyCompany("Clemens Fischer")] +[assembly: AssemblyCopyright("© 2017 Clemens Fischer")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyVersion("4.1.0")] +[assembly: AssemblyFileVersion("4.1.0")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] diff --git a/MBTiles/WPF/packages.config b/MBTiles/WPF/packages.config new file mode 100644 index 00000000..7b12ab4d --- /dev/null +++ b/MBTiles/WPF/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/MapControl.sln b/MapControl.sln index b711a639..effaf74a 100644 --- a/MapControl.sln +++ b/MapControl.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25123.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.26730.16 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MapControl", "MapControl", "{52AECE49-F314-4F76-98F2-FA800F07824B}" EndProject @@ -21,6 +21,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FileDbCache.WPF", "Caching\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FileDbCache.UWP", "Caching\FileDbCache.UWP\FileDbCache.UWP.csproj", "{3FF37D40-F770-45B2-95DD-7A84093E1425}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MBTiles", "MBTiles", "{CEAD0EA1-A971-4F5F-9EAE-C72F75D1F737}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MBTiles.WPF", "MBTiles\WPF\MBTiles.WPF.csproj", "{38B18AB6-6E70-4696-8FB4-E8C8E12BF50C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MBTiles.UWP", "MBTiles\UWP\MBTiles.UWP.csproj", "{46D812C6-5354-46A6-8604-D4497E17E2A2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -135,6 +141,38 @@ Global {3FF37D40-F770-45B2-95DD-7A84093E1425}.Release|x64.Build.0 = Release|Any CPU {3FF37D40-F770-45B2-95DD-7A84093E1425}.Release|x86.ActiveCfg = Release|Any CPU {3FF37D40-F770-45B2-95DD-7A84093E1425}.Release|x86.Build.0 = Release|Any CPU + {38B18AB6-6E70-4696-8FB4-E8C8E12BF50C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {38B18AB6-6E70-4696-8FB4-E8C8E12BF50C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {38B18AB6-6E70-4696-8FB4-E8C8E12BF50C}.Debug|ARM.ActiveCfg = Debug|Any CPU + {38B18AB6-6E70-4696-8FB4-E8C8E12BF50C}.Debug|ARM.Build.0 = Debug|Any CPU + {38B18AB6-6E70-4696-8FB4-E8C8E12BF50C}.Debug|x64.ActiveCfg = Debug|Any CPU + {38B18AB6-6E70-4696-8FB4-E8C8E12BF50C}.Debug|x64.Build.0 = Debug|Any CPU + {38B18AB6-6E70-4696-8FB4-E8C8E12BF50C}.Debug|x86.ActiveCfg = Debug|Any CPU + {38B18AB6-6E70-4696-8FB4-E8C8E12BF50C}.Debug|x86.Build.0 = Debug|Any CPU + {38B18AB6-6E70-4696-8FB4-E8C8E12BF50C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {38B18AB6-6E70-4696-8FB4-E8C8E12BF50C}.Release|Any CPU.Build.0 = Release|Any CPU + {38B18AB6-6E70-4696-8FB4-E8C8E12BF50C}.Release|ARM.ActiveCfg = Release|Any CPU + {38B18AB6-6E70-4696-8FB4-E8C8E12BF50C}.Release|ARM.Build.0 = Release|Any CPU + {38B18AB6-6E70-4696-8FB4-E8C8E12BF50C}.Release|x64.ActiveCfg = Release|Any CPU + {38B18AB6-6E70-4696-8FB4-E8C8E12BF50C}.Release|x64.Build.0 = Release|Any CPU + {38B18AB6-6E70-4696-8FB4-E8C8E12BF50C}.Release|x86.ActiveCfg = Release|Any CPU + {38B18AB6-6E70-4696-8FB4-E8C8E12BF50C}.Release|x86.Build.0 = Release|Any CPU + {46D812C6-5354-46A6-8604-D4497E17E2A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {46D812C6-5354-46A6-8604-D4497E17E2A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {46D812C6-5354-46A6-8604-D4497E17E2A2}.Debug|ARM.ActiveCfg = Debug|Any CPU + {46D812C6-5354-46A6-8604-D4497E17E2A2}.Debug|ARM.Build.0 = Debug|Any CPU + {46D812C6-5354-46A6-8604-D4497E17E2A2}.Debug|x64.ActiveCfg = Debug|Any CPU + {46D812C6-5354-46A6-8604-D4497E17E2A2}.Debug|x64.Build.0 = Debug|Any CPU + {46D812C6-5354-46A6-8604-D4497E17E2A2}.Debug|x86.ActiveCfg = Debug|Any CPU + {46D812C6-5354-46A6-8604-D4497E17E2A2}.Debug|x86.Build.0 = Debug|Any CPU + {46D812C6-5354-46A6-8604-D4497E17E2A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {46D812C6-5354-46A6-8604-D4497E17E2A2}.Release|Any CPU.Build.0 = Release|Any CPU + {46D812C6-5354-46A6-8604-D4497E17E2A2}.Release|ARM.ActiveCfg = Release|Any CPU + {46D812C6-5354-46A6-8604-D4497E17E2A2}.Release|ARM.Build.0 = Release|Any CPU + {46D812C6-5354-46A6-8604-D4497E17E2A2}.Release|x64.ActiveCfg = Release|Any CPU + {46D812C6-5354-46A6-8604-D4497E17E2A2}.Release|x64.Build.0 = Release|Any CPU + {46D812C6-5354-46A6-8604-D4497E17E2A2}.Release|x86.ActiveCfg = Release|Any CPU + {46D812C6-5354-46A6-8604-D4497E17E2A2}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -146,5 +184,10 @@ Global {AA62B4AA-1CA3-4C20-BEB7-B824D0FC4BD1} = {8F2103C2-78AF-4810-8FB9-67572F50C8FC} {AD1CB53E-7AA4-4EC0-B901-B4E0E2665133} = {6A596588-F93F-47CC-BE5D-58C3B34ADDEB} {3FF37D40-F770-45B2-95DD-7A84093E1425} = {6A596588-F93F-47CC-BE5D-58C3B34ADDEB} + {38B18AB6-6E70-4696-8FB4-E8C8E12BF50C} = {CEAD0EA1-A971-4F5F-9EAE-C72F75D1F737} + {46D812C6-5354-46A6-8604-D4497E17E2A2} = {CEAD0EA1-A971-4F5F-9EAE-C72F75D1F737} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {458346DD-B23F-4FDC-8F9D-A10F1882A4DB} EndGlobalSection EndGlobal diff --git a/MapControl/Shared/BingMapsTileLayer.cs b/MapControl/Shared/BingMapsTileLayer.cs index 49672a1e..6aae5616 100644 --- a/MapControl/Shared/BingMapsTileLayer.cs +++ b/MapControl/Shared/BingMapsTileLayer.cs @@ -45,7 +45,7 @@ namespace MapControl public MapMode Mode { get; set; } public string Culture { get; set; } - public Uri LogoImageUri { get; set; } + public Uri LogoImageUri { get; private set; } private async void OnLoaded(object sender, RoutedEventArgs e) { diff --git a/MapControl/Shared/MapTileLayer.cs b/MapControl/Shared/MapTileLayer.cs index 8343d4ea..b17e4ee8 100644 --- a/MapControl/Shared/MapTileLayer.cs +++ b/MapControl/Shared/MapTileLayer.cs @@ -344,7 +344,12 @@ namespace MapControl if (parentMap != null && TileGrid != null && TileSource != null) { var maxZoomLevel = Math.Min(TileGrid.ZoomLevel, MaxZoomLevel); - var minZoomLevel = parentMap.MapLayer == this ? MinZoomLevel : maxZoomLevel; // load background tiles only if this is the base layer + var minZoomLevel = MinZoomLevel; + + if (minZoomLevel < maxZoomLevel && parentMap.MapLayer != this) // load lower tiles only in a base layer + { + minZoomLevel = maxZoomLevel; + } for (var z = minZoomLevel; z <= maxZoomLevel; z++) { diff --git a/MapControl/UWP/MapBase.UWP.cs b/MapControl/UWP/MapBase.UWP.cs index 9dacb391..5d642812 100644 --- a/MapControl/UWP/MapBase.UWP.cs +++ b/MapControl/UWP/MapBase.UWP.cs @@ -53,11 +53,13 @@ namespace MapControl style.Setters.Add(new Setter(BackgroundProperty, new SolidColorBrush(Colors.Transparent))); Style = style; - Clip = new RectangleGeometry(); - SizeChanged += (s, e) => { - Clip.Rect = new Rect(0d, 0d, e.NewSize.Width, e.NewSize.Height); + Clip = new RectangleGeometry + { + Rect = new Rect(0d, 0d, e.NewSize.Width, e.NewSize.Height) + }; + ResetTransformCenter(); UpdateTransform(); }; diff --git a/MapControl/UWP/Properties/AssemblyInfo.cs b/MapControl/UWP/Properties/AssemblyInfo.cs index 1360c2f0..190e526b 100644 --- a/MapControl/UWP/Properties/AssemblyInfo.cs +++ b/MapControl/UWP/Properties/AssemblyInfo.cs @@ -1,8 +1,8 @@ using System.Reflection; using System.Runtime.InteropServices; -[assembly: AssemblyTitle("XAML Map Control for UWP")] -[assembly: AssemblyDescription("XAML Map Control Library for UWP")] +[assembly: AssemblyTitle("XAML Map Control (UWP)")] +[assembly: AssemblyDescription("XAML Map Control Library")] [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("© 2017 Clemens Fischer")] diff --git a/MapControl/UWP/TileSource.UWP.cs b/MapControl/UWP/TileSource.UWP.cs index 46671b21..af6aecd4 100644 --- a/MapControl/UWP/TileSource.UWP.cs +++ b/MapControl/UWP/TileSource.UWP.cs @@ -53,17 +53,16 @@ namespace MapControl } else if (TileAvailable(response.Headers)) { - var bitmapImage = new BitmapImage(); - using (var stream = new InMemoryRandomAccessStream()) { await response.Content.WriteToStreamAsync(stream); stream.Seek(0); + var bitmapImage = new BitmapImage(); await bitmapImage.SetSourceAsync(stream); - } - imageSource = bitmapImage; + imageSource = bitmapImage; + } } } } diff --git a/MapControl/WPF/Properties/AssemblyInfo.cs b/MapControl/WPF/Properties/AssemblyInfo.cs index f4ab9ad8..836cbd56 100644 --- a/MapControl/WPF/Properties/AssemblyInfo.cs +++ b/MapControl/WPF/Properties/AssemblyInfo.cs @@ -2,8 +2,8 @@ using System.Runtime.InteropServices; using System.Windows; -[assembly: AssemblyTitle("XAML Map Control for WPF")] -[assembly: AssemblyDescription("XAML Map Control Library for WPF")] +[assembly: AssemblyTitle("XAML Map Control (WPF)")] +[assembly: AssemblyDescription("XAML Map Control Library")] [assembly: AssemblyProduct("XAML Map Control")] [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("© 2017 Clemens Fischer")] diff --git a/SampleApps/Shared/MapLayers.cs b/SampleApps/Shared/MapLayers.cs index 9e09bded..9ad942e8 100644 --- a/SampleApps/Shared/MapLayers.cs +++ b/SampleApps/Shared/MapLayers.cs @@ -24,60 +24,33 @@ namespace ViewModel MapTileLayer.OpenStreetMapTileLayer }, { - "OpenStreetMap German Style", + "OpenStreetMap German", new MapTileLayer { SourceName = "OpenStreetMap German", - Description = "© [OpenStreetMap Contributors](http://www.openstreetmap.org/copyright)", + Description = "© [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)", TileSource = new TileSource { UriFormat = "http://{c}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png" }, MaxZoomLevel = 19 } }, { - "Thunderforest OpenCycleMap", + "Stamen Terrain", new MapTileLayer { - SourceName = "Thunderforest OpenCycleMap", - Description = "Maps © [Thunderforest](http://www.thunderforest.com/), Data © [OpenStreetMap Contributors](http://www.openstreetmap.org/copyright)", - TileSource = new TileSource { UriFormat = "http://{c}.tile.thunderforest.com/cycle/{z}/{x}/{y}.png" } + 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)", + TileSource = new TileSource { UriFormat = "http://tile.stamen.com/terrain/{z}/{x}/{y}.png" }, + MaxZoomLevel = 17 } }, { - "Thunderforest Landscape", + "Stamen Toner Light", new MapTileLayer { - SourceName = "Thunderforest Landscape", - Description = "Maps © [Thunderforest](http://www.thunderforest.com/), Data © [OpenStreetMap Contributors](http://www.openstreetmap.org/copyright)", - TileSource = new TileSource { UriFormat = "http://{c}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png" } - } - }, - { - "Thunderforest Outdoors", - new MapTileLayer - { - SourceName = "Thunderforest Outdoors", - Description = "Maps © [Thunderforest](http://www.thunderforest.com/), Data © [OpenStreetMap Contributors](http://www.openstreetmap.org/copyright)", - TileSource = new TileSource { UriFormat = "http://{c}.tile.thunderforest.com/outdoors/{z}/{x}/{y}.png" } - } - }, - { - "Thunderforest Transport", - new MapTileLayer - { - SourceName = "Thunderforest Transport", - Description = "Maps © [Thunderforest](http://www.thunderforest.com/), Data © [OpenStreetMap Contributors](http://www.openstreetmap.org/copyright)", - TileSource = new TileSource { UriFormat = "http://{c}.tile.thunderforest.com/transport/{z}/{x}/{y}.png" } - } - }, - { - "Thunderforest Transport Dark", - new MapTileLayer - { - SourceName = "Thunderforest Transport Dark", - Description = "Maps © [Thunderforest](http://www.thunderforest.com/), Data © [OpenStreetMap Contributors](http://www.openstreetmap.org/copyright)", - TileSource = new TileSource { UriFormat = "http://{c}.tile.thunderforest.com/transport-dark/{z}/{x}/{y}.png" }, - MapForeground = new SolidColorBrush(Colors.White), - MapBackground = new SolidColorBrush(Colors.Black) + 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)", + TileSource = new TileSource { UriFormat = "http://tile.stamen.com/toner-lite/{z}/{x}/{y}.png" }, + MaxZoomLevel = 18 } }, { @@ -172,12 +145,9 @@ namespace ViewModel public List MapLayerNames { get; } = new List { "OpenStreetMap", - "OpenStreetMap German Style", - "Thunderforest OpenCycleMap", - //"Thunderforest Landscape", - //"Thunderforest Outdoors", - //"Thunderforest Transport", - //"Thunderforest Transport Dark", + "OpenStreetMap German", + "Stamen Terrain", + "Stamen Toner Light", "OpenStreetMap WMS", "OpenStreetMap TOPO WMS" }; diff --git a/SampleApps/UniversalApp/App.xaml.cs b/SampleApps/UniversalApp/App.xaml.cs index fdbc85a7..47c49883 100644 --- a/SampleApps/UniversalApp/App.xaml.cs +++ b/SampleApps/UniversalApp/App.xaml.cs @@ -11,8 +11,8 @@ namespace UniversalApp { public App() { - this.InitializeComponent(); - this.Suspending += OnSuspending; + InitializeComponent(); + Suspending += OnSuspending; } protected override void OnLaunched(LaunchActivatedEventArgs e) diff --git a/SampleApps/WpfApplication/MainWindow.xaml b/SampleApps/WpfApplication/MainWindow.xaml index e8ab2fb2..04563d85 100644 --- a/SampleApps/WpfApplication/MainWindow.xaml +++ b/SampleApps/WpfApplication/MainWindow.xaml @@ -26,7 +26,7 @@