diff --git a/MapControl/Shared/ImageLoader.cs b/MapControl/Shared/ImageLoader.cs index fc2320dc..5b0f401e 100644 --- a/MapControl/Shared/ImageLoader.cs +++ b/MapControl/Shared/ImageLoader.cs @@ -34,7 +34,7 @@ namespace MapControl { imageSource = await LoadLocalImageAsync(uri); } - else if (uri.Scheme == "http") + else if (uri.Scheme == "http" || uri.Scheme == "https") { imageSource = await LoadHttpImageAsync(uri); } diff --git a/MapControl/Shared/MapTileLayer.cs b/MapControl/Shared/MapTileLayer.cs index d9ca85a2..676cb21b 100644 --- a/MapControl/Shared/MapTileLayer.cs +++ b/MapControl/Shared/MapTileLayer.cs @@ -41,7 +41,7 @@ namespace MapControl { SourceName = "OpenStreetMap", Description = "© [OpenStreetMap Contributors](http://www.openstreetmap.org/copyright)", - TileSource = new TileSource { UriFormat = "http://{c}.tile.openstreetmap.org/{z}/{x}/{y}.png" }, + TileSource = new TileSource { UriFormat = "https://{c}.tile.openstreetmap.org/{z}/{x}/{y}.png" }, MaxZoomLevel = 19 }; } @@ -374,7 +374,7 @@ namespace MapControl if (equivalentTile != null) { - tile.SetImage(equivalentTile.Image.Source, false); // do not animate to avoid flicker when crossing 180° longitude + tile.SetImage(equivalentTile.Image.Source, false); // no fade-in animation } } diff --git a/MapControl/UWP/Tile.UWP.cs b/MapControl/UWP/Tile.UWP.cs index e0b2aeb4..a8366a53 100644 --- a/MapControl/UWP/Tile.UWP.cs +++ b/MapControl/UWP/Tile.UWP.cs @@ -28,7 +28,8 @@ namespace MapControl } else { - Image.BeginAnimation(UIElement.OpacityProperty, new DoubleAnimation { To = 1d, Duration = FadeDuration }); + Image.BeginAnimation(UIElement.OpacityProperty, new DoubleAnimation { From = 0d, To = 1d, Duration = FadeDuration, FillBehavior = FillBehavior.Stop }); + Image.Opacity = 1d; } } else @@ -46,7 +47,8 @@ namespace MapControl bitmapImage.ImageOpened -= BitmapImageOpened; bitmapImage.ImageFailed -= BitmapImageFailed; - Image.BeginAnimation(UIElement.OpacityProperty, new DoubleAnimation { To = 1d, Duration = FadeDuration }); + Image.BeginAnimation(UIElement.OpacityProperty, new DoubleAnimation { From = 0d, To = 1d, Duration = FadeDuration, FillBehavior = FillBehavior.Stop }); + Image.Opacity = 1d; } private void BitmapImageFailed(object sender, ExceptionRoutedEventArgs e) diff --git a/MapControl/WPF/Tile.WPF.cs b/MapControl/WPF/Tile.WPF.cs index 27b1663b..09ddd05c 100644 --- a/MapControl/WPF/Tile.WPF.cs +++ b/MapControl/WPF/Tile.WPF.cs @@ -28,7 +28,8 @@ namespace MapControl } else { - Image.BeginAnimation(UIElement.OpacityProperty, new DoubleAnimation(1d, FadeDuration)); + Image.BeginAnimation(UIElement.OpacityProperty, new DoubleAnimation(0d, 1d, FadeDuration, FillBehavior.Stop)); + Image.Opacity = 1d; } } else @@ -46,7 +47,8 @@ namespace MapControl bitmapSource.DownloadCompleted -= BitmapDownloadCompleted; bitmapSource.DownloadFailed -= BitmapDownloadFailed; - Image.BeginAnimation(UIElement.OpacityProperty, new DoubleAnimation(1d, FadeDuration)); + Image.BeginAnimation(UIElement.OpacityProperty, new DoubleAnimation(0d, 1d, FadeDuration, FillBehavior.Stop)); + Image.Opacity = 1d; } private void BitmapDownloadFailed(object sender, ExceptionEventArgs e) diff --git a/SampleApps/Shared/MapLayers.cs b/SampleApps/Shared/MapLayers.cs index 6b4518ef..870e4a63 100644 --- a/SampleApps/Shared/MapLayers.cs +++ b/SampleApps/Shared/MapLayers.cs @@ -23,20 +23,6 @@ namespace ViewModel "OpenStreetMap", MapTileLayer.OpenStreetMapTileLayer }, - { - "OpenStreetMap Files", - new MapTileLayer - { - SourceName = "OpenStreetMap Files", - Description = "© [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)", -#if WINDOWS_UWP - TileSource = new TileSource { UriFormat = @"C:\Users\Clemens\AppData\Local\Packages\XamlMapControl.UniversalApp_2kan67jdewwkc\TempState\OpenStreetMap\{z}\{x}\{y}.png" }, -#else - TileSource = new TileSource { UriFormat = @"C:\ProgramData\MapControl\TileCache\OpenStreetMap\{z}\{x}\{y}.png" }, -#endif - MaxZoomLevel = 19 - } - }, { "OpenStreetMap German", new MapTileLayer @@ -132,54 +118,10 @@ namespace ViewModel { Description = "© [SevenCs GmbH](http://www.sevencs.com)", ServiceUri = new Uri("http://chartserver4.sevencs.com:8080"), - Layers = "ENC" + Layers = "ENC", + MaxBoundingBoxWidth = 360 } - }, - { - "ECDIS DAY_BRIGHT", - new WmsImageLayer - { - Description = "ECDIS WMS DAY_BRIGHT", - ServiceUri = new Uri("http://as113121:8080/ECDIS?LAYERS=ENC&LIGHTS=TRUE&COLOR=0&DETAILS=2") - } - }, - { - "ECDIS DAY_WHITEBACK", - new WmsImageLayer - { - Description = "ECDIS WMS DAY_WHITEBACK", - ServiceUri = new Uri("http://as113121:8080/ECDIS?LAYERS=ENC&LIGHTS=TRUE&COLOR=1&DETAILS=2") - } - }, - { - "ECDIS DAY_BLACKBACK", - new WmsImageLayer - { - Description = "ECDIS WMS DAY_BLACKBACK", - ServiceUri = new Uri("http://as113121:8080/ECDIS?LAYERS=ENC&LIGHTS=TRUE&COLOR=2&DETAILS=2"), - MapForeground = new SolidColorBrush(Colors.White) - } - }, - { - "ECDIS DUSK", - new WmsImageLayer - { - Description = "ECDIS WMS DUSK", - ServiceUri = new Uri("http://as113121:8080/ECDIS?LAYERS=ENC&LIGHTS=TRUE&COLOR=3&DETAILS=2"), - MapForeground = new SolidColorBrush(Colors.Gray), - MapBackground = new SolidColorBrush(Colors.Black) - } - }, - { - "ECDIS NIGHT", - new WmsImageLayer - { - Description = "ECDIS WMS NIGHT", - ServiceUri = new Uri("http://as113121:8080/ECDIS?LAYERS=ENC&LIGHTS=TRUE&COLOR=4&DETAILS=2"), - MapForeground = new SolidColorBrush(Colors.Gray), - MapBackground = new SolidColorBrush(Colors.Black) - } - }, + } }; private string currentMapLayerName = "OpenStreetMap"; @@ -208,23 +150,17 @@ namespace ViewModel public List MapLayerNames { get; } = new List { "OpenStreetMap", - "OpenStreetMap Files", "OpenStreetMap German", "Stamen Terrain", "Stamen Toner Light", "OpenStreetMap WMS", "OpenStreetMap TOPO WMS", - "SevenCs ChartServer", - "ECDIS DAY_BRIGHT", - "ECDIS DAY_WHITEBACK", - "ECDIS DAY_BLACKBACK", - "ECDIS DUSK", - "ECDIS NIGHT", + "SevenCs ChartServer" }; public MapLayers() { - BingMapsTileLayer.ApiKey = ""; + //BingMapsTileLayer.ApiKey = "..."; // Bing Maps TileLayers with tile URLs retrieved from the Imagery Metadata Service // (see http://msdn.microsoft.com/en-us/library/ff701716.aspx). @@ -237,15 +173,6 @@ namespace ViewModel MapLayerNames.Add("Bing Maps Aerial"); MapLayerNames.Add("Bing Maps Aerial with Labels"); } - - //var t = new System.Windows.Threading.DispatcherTimer { Interval = TimeSpan.FromSeconds(1) }; - //t.Tick += async (s, e) => - //{ - // var layers = await ((WmsImageLayer)mapLayers["OpenStreetMap WMS"]).GetLayerNamesAsync(); - // System.Diagnostics.Debug.WriteLine(string.Join(", ", layers)); - // t.Stop(); - //}; - //t.Start(); } } } diff --git a/SampleApps/UniversalApp/MainPage.xaml.cs b/SampleApps/UniversalApp/MainPage.xaml.cs index 6b104b39..c44aafe2 100644 --- a/SampleApps/UniversalApp/MainPage.xaml.cs +++ b/SampleApps/UniversalApp/MainPage.xaml.cs @@ -1,11 +1,9 @@ using MapControl; using MapControl.Caching; using ViewModel; -using Windows.UI; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Media; namespace UniversalApp { @@ -15,40 +13,11 @@ namespace UniversalApp public MainPage() { - TileImageLoader.Cache = new ImageFileCache(TileImageLoader.DefaultCacheFolder); + //TileImageLoader.Cache = new ImageFileCache(TileImageLoader.DefaultCacheFolder); //TileImageLoader.Cache = new FileDbCache(TileImageLoader.DefaultCacheFolder); InitializeComponent(); DataContext = ViewModel; - - for (var x = -180d; x < 180d; x += 15d) - { - var location = new Location(0d, x); - - var locations = new LocationCollection - { - new Location(0, x - 5), - new Location(5, x), - new Location(0, x + 5), - new Location(-5, x) - }; - - map.Children.Add(new MapPolygon - { - Fill = new SolidColorBrush(Colors.Red) { Opacity = 0.25 }, - Stroke = new SolidColorBrush(Colors.Red), - StrokeThickness = 2, - StrokeLineJoin = PenLineJoin.Round, - Locations = locations, - Location = location, - }); - - map.Children.Add(new Pushpin - { - Content = x, - Location = location, - }); - } } private void ImageOpacitySliderValueChanged(object sender, RangeBaseValueChangedEventArgs e) diff --git a/SampleApps/WpfApplication/MainWindow.xaml.cs b/SampleApps/WpfApplication/MainWindow.xaml.cs index 645d6974..6301684a 100644 --- a/SampleApps/WpfApplication/MainWindow.xaml.cs +++ b/SampleApps/WpfApplication/MainWindow.xaml.cs @@ -11,9 +11,8 @@ namespace WpfApplication { public MainWindow() { - TileImageLoader.Cache = new MapControl.Caching.ImageFileCache(TileImageLoader.DefaultCacheFolder); + //TileImageLoader.Cache = new MapControl.Caching.ImageFileCache(TileImageLoader.DefaultCacheFolder); //TileImageLoader.Cache = new MapControl.Caching.FileDbCache(TileImageLoader.DefaultCacheFolder); - //TileImageLoader.Cache = null; InitializeComponent(); }