2017-06-25 23:05:48 +02:00
|
|
|
|
using MapControl;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.ComponentModel;
|
2021-07-01 22:07:46 +02:00
|
|
|
|
#if WINUI
|
|
|
|
|
|
using Microsoft.UI;
|
|
|
|
|
|
using Microsoft.UI.Xaml;
|
|
|
|
|
|
using Microsoft.UI.Xaml.Media;
|
2021-11-17 23:25:10 +01:00
|
|
|
|
#elif UWP
|
2017-06-25 23:05:48 +02:00
|
|
|
|
using Windows.UI;
|
|
|
|
|
|
using Windows.UI.Xaml;
|
|
|
|
|
|
using Windows.UI.Xaml.Media;
|
|
|
|
|
|
#else
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2021-10-28 20:26:51 +02:00
|
|
|
|
namespace SampleApplication
|
2017-06-25 23:05:48 +02:00
|
|
|
|
{
|
2020-10-24 10:35:08 +02:00
|
|
|
|
public class MapLayers : INotifyPropertyChanged
|
2017-06-25 23:05:48 +02:00
|
|
|
|
{
|
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
|
|
|
|
|
|
|
private readonly Dictionary<string, UIElement> mapLayers = new Dictionary<string, UIElement>
|
|
|
|
|
|
{
|
|
|
|
|
|
{
|
|
|
|
|
|
"OpenStreetMap",
|
2020-04-19 12:47:39 +02:00
|
|
|
|
new MapTileLayer
|
|
|
|
|
|
{
|
2021-09-22 16:58:31 +02:00
|
|
|
|
TileSource = new TileSource { UriFormat = "https://tile.openstreetmap.org/{z}/{x}/{y}.png" },
|
2020-04-19 12:47:39 +02:00
|
|
|
|
SourceName = "OpenStreetMap",
|
2020-10-25 16:09:09 +01:00
|
|
|
|
Description = "© [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)"
|
2020-04-19 12:47:39 +02:00
|
|
|
|
}
|
2017-06-25 23:05:48 +02:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2017-10-07 17:43:28 +02:00
|
|
|
|
"OpenStreetMap German",
|
2017-06-25 23:05:48 +02:00
|
|
|
|
new MapTileLayer
|
|
|
|
|
|
{
|
2021-09-22 16:58:31 +02:00
|
|
|
|
TileSource = new TileSource { UriFormat = "https://tile.openstreetmap.de/{z}/{x}/{y}.png" },
|
2017-06-25 23:05:48 +02:00
|
|
|
|
SourceName = "OpenStreetMap German",
|
2020-10-25 16:09:09 +01:00
|
|
|
|
Description = "© [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)"
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
"OpenStreetMap French",
|
|
|
|
|
|
new MapTileLayer
|
|
|
|
|
|
{
|
2021-09-22 16:58:31 +02:00
|
|
|
|
TileSource = new TileSource { UriFormat = "https://tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png" },
|
2020-10-25 16:09:09 +01:00
|
|
|
|
SourceName = "OpenStreetMap French",
|
|
|
|
|
|
Description = "© [OpenStreetMap France](https://www.openstreetmap.fr/mentions-legales/) © [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)"
|
2017-06-25 23:05:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2020-10-23 23:35:48 +02:00
|
|
|
|
"OpenTopoMap",
|
2017-06-25 23:05:48 +02:00
|
|
|
|
new MapTileLayer
|
|
|
|
|
|
{
|
2021-09-22 16:58:31 +02:00
|
|
|
|
TileSource = new TileSource { UriFormat = "https://tile.opentopomap.org/{z}/{x}/{y}.png" },
|
2020-10-23 23:35:48 +02:00
|
|
|
|
SourceName = "OpenTopoMap",
|
2020-10-25 16:09:09 +01:00
|
|
|
|
Description = "© [OpenTopoMap](https://opentopomap.org/) © [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)",
|
2017-10-07 17:43:28 +02:00
|
|
|
|
MaxZoomLevel = 17
|
2017-06-25 23:05:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2020-10-23 23:35:48 +02:00
|
|
|
|
"Seamarks",
|
2017-06-25 23:05:48 +02:00
|
|
|
|
new MapTileLayer
|
|
|
|
|
|
{
|
2020-10-23 23:35:48 +02:00
|
|
|
|
TileSource = new TileSource { UriFormat = "http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png" },
|
|
|
|
|
|
SourceName = "OpenSeaMap",
|
|
|
|
|
|
MinZoomLevel = 9,
|
2017-10-07 17:43:28 +02:00
|
|
|
|
MaxZoomLevel = 18
|
2017-06-25 23:05:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-03-20 20:50:19 +01:00
|
|
|
|
{
|
2020-10-23 23:35:48 +02:00
|
|
|
|
"Bing Maps Road",
|
|
|
|
|
|
new BingMapsTileLayer
|
2020-03-20 20:50:19 +01:00
|
|
|
|
{
|
2020-10-23 23:35:48 +02:00
|
|
|
|
Mode = BingMapsTileLayer.MapMode.Road,
|
|
|
|
|
|
SourceName = "Bing Maps Road",
|
|
|
|
|
|
Description = "© [Microsoft](http://www.bing.com/maps/)"
|
2020-03-20 20:50:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-03-20 21:29:43 +01:00
|
|
|
|
{
|
2020-10-23 23:35:48 +02:00
|
|
|
|
"Bing Maps Aerial",
|
|
|
|
|
|
new BingMapsTileLayer
|
|
|
|
|
|
{
|
|
|
|
|
|
Mode = BingMapsTileLayer.MapMode.Aerial,
|
|
|
|
|
|
SourceName = "Bing Maps Aerial",
|
|
|
|
|
|
Description = "© [Microsoft](http://www.bing.com/maps/)",
|
|
|
|
|
|
MapForeground = new SolidColorBrush(Colors.White),
|
|
|
|
|
|
MapBackground = new SolidColorBrush(Colors.Black)
|
|
|
|
|
|
}
|
2020-03-20 21:29:43 +01:00
|
|
|
|
},
|
2020-04-19 12:47:39 +02:00
|
|
|
|
{
|
2020-10-23 23:35:48 +02:00
|
|
|
|
"Bing Maps Aerial with Labels",
|
|
|
|
|
|
new BingMapsTileLayer
|
2020-04-19 12:47:39 +02:00
|
|
|
|
{
|
2020-10-23 23:35:48 +02:00
|
|
|
|
Mode = BingMapsTileLayer.MapMode.AerialWithLabels,
|
|
|
|
|
|
SourceName = "Bing Maps Hybrid",
|
|
|
|
|
|
Description = "© [Microsoft](http://www.bing.com/maps/)",
|
|
|
|
|
|
MapForeground = new SolidColorBrush(Colors.White),
|
|
|
|
|
|
MapBackground = new SolidColorBrush(Colors.Black)
|
2020-04-19 12:47:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-10-25 16:09:09 +01:00
|
|
|
|
{
|
|
|
|
|
|
"TopPlusOpen WMTS",
|
|
|
|
|
|
new WmtsTileLayer
|
|
|
|
|
|
{
|
|
|
|
|
|
SourceName = "TopPlusOpen",
|
|
|
|
|
|
Description = "© [BKG](https://gdz.bkg.bund.de/index.php/default/webdienste/topplus-produkte/wmts-topplusopen-wmts-topplus-open.html)",
|
|
|
|
|
|
CapabilitiesUri = new Uri("https://sgx.geodatenzentrum.de/wmts_topplus_open/1.0.0/WMTSCapabilities.xml")
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
"TopPlusOpen WMS",
|
|
|
|
|
|
new WmsImageLayer
|
|
|
|
|
|
{
|
|
|
|
|
|
Description = "© [BKG](https://gdz.bkg.bund.de/index.php/default/webdienste/topplus-produkte/wms-topplusopen-mit-layer-fur-normalausgabe-und-druck-wms-topplus-open.html)",
|
|
|
|
|
|
ServiceUri = new Uri("https://sgx.geodatenzentrum.de/wms_topplus_open")
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
"OpenStreetMap WMS",
|
|
|
|
|
|
new WmsImageLayer
|
|
|
|
|
|
{
|
|
|
|
|
|
Description = "© [terrestris GmbH & Co. KG](http://ows.terrestris.de/) © [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)",
|
|
|
|
|
|
ServiceUri = new Uri("http://ows.terrestris.de/osm/service")
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2017-06-25 23:05:48 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
private string currentMapLayerName = "OpenStreetMap";
|
|
|
|
|
|
|
|
|
|
|
|
public string CurrentMapLayerName
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return currentMapLayerName; }
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
currentMapLayerName = value;
|
|
|
|
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CurrentMapLayerName)));
|
|
|
|
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CurrentMapLayer)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public UIElement CurrentMapLayer
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return mapLayers[currentMapLayerName]; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public UIElement SeamarksLayer
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return mapLayers["Seamarks"]; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<string> MapLayerNames { get; } = new List<string>
|
|
|
|
|
|
{
|
|
|
|
|
|
"OpenStreetMap",
|
2017-10-07 17:43:28 +02:00
|
|
|
|
"OpenStreetMap German",
|
2020-10-25 16:09:09 +01:00
|
|
|
|
"OpenStreetMap French",
|
2020-10-23 23:35:48 +02:00
|
|
|
|
"OpenTopoMap",
|
2020-03-20 20:50:19 +01:00
|
|
|
|
"TopPlusOpen WMTS",
|
2020-10-23 23:35:48 +02:00
|
|
|
|
"TopPlusOpen WMS",
|
|
|
|
|
|
"OpenStreetMap WMS",
|
2017-06-25 23:05:48 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
public MapLayers()
|
|
|
|
|
|
{
|
2020-10-24 10:29:12 +02:00
|
|
|
|
// Add Bing Maps TileLayers with tile URLs retrieved from the Imagery Metadata Service
|
2020-10-24 10:23:16 +02:00
|
|
|
|
// (http://msdn.microsoft.com/en-us/library/ff701716.aspx).
|
|
|
|
|
|
// A Bing Maps API Key (http://msdn.microsoft.com/en-us/library/ff428642.aspx) is required
|
2017-06-25 23:05:48 +02:00
|
|
|
|
// for using these layers and must be assigned to the static BingMapsTileLayer.ApiKey property.
|
|
|
|
|
|
|
2017-10-08 17:35:07 +02:00
|
|
|
|
if (!string.IsNullOrEmpty(BingMapsTileLayer.ApiKey))
|
|
|
|
|
|
{
|
|
|
|
|
|
MapLayerNames.Add("Bing Maps Road");
|
|
|
|
|
|
MapLayerNames.Add("Bing Maps Aerial");
|
|
|
|
|
|
MapLayerNames.Add("Bing Maps Aerial with Labels");
|
|
|
|
|
|
}
|
2017-06-25 23:05:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|