mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
Reworked sample applications
This commit is contained in:
parent
e2f4fc13b1
commit
1d1b2942b4
9 changed files with 468 additions and 283 deletions
|
|
@ -1,24 +1,5 @@
|
|||
using MapControl;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#if WINUI
|
||||
using Microsoft.UI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Microsoft.UI.Xaml.Media.Imaging;
|
||||
#elif UWP
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
#else
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
#endif
|
||||
|
||||
namespace SampleApplication
|
||||
{
|
||||
|
|
@ -40,164 +21,8 @@ namespace SampleApplication
|
|||
public List<PointItem> Pushpins { get; } = new List<PointItem>();
|
||||
public List<PolylineItem> Polylines { get; } = new List<PolylineItem>();
|
||||
|
||||
public Dictionary<string, MapProjection> MapProjections { get; } = new Dictionary<string, MapProjection>
|
||||
{
|
||||
{ "Web Mercator", new WebMercatorProjection() },
|
||||
{ "World Mercator", new WorldMercatorProjection() },
|
||||
{ "Equirectangular", new EquirectangularProjection() },
|
||||
{ "Orthographic", new OrthographicProjection() },
|
||||
{ "Gnomonic", new GnomonicProjection() },
|
||||
{ "Stereographic", new StereographicProjection() }
|
||||
};
|
||||
|
||||
public Dictionary<string, UIElement> MapLayers { get; } = new Dictionary<string, UIElement>
|
||||
{
|
||||
{
|
||||
"OpenStreetMap",
|
||||
new MapTileLayer
|
||||
{
|
||||
TileSource = new TileSource { UriFormat = "https://tile.openstreetmap.org/{z}/{x}/{y}.png" },
|
||||
SourceName = "OpenStreetMap",
|
||||
Description = "© [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)"
|
||||
}
|
||||
},
|
||||
{
|
||||
"OpenStreetMap German",
|
||||
new MapTileLayer
|
||||
{
|
||||
TileSource = new TileSource { UriFormat = "https://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png" },
|
||||
SourceName = "OpenStreetMap German",
|
||||
Description = "© [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)"
|
||||
}
|
||||
},
|
||||
{
|
||||
"OpenStreetMap French",
|
||||
new MapTileLayer
|
||||
{
|
||||
TileSource = new TileSource { UriFormat = "http://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png" },
|
||||
SourceName = "OpenStreetMap French",
|
||||
Description = "© [OpenStreetMap France](https://www.openstreetmap.fr/mentions-legales/) © [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)"
|
||||
}
|
||||
},
|
||||
{
|
||||
"OpenTopoMap",
|
||||
new MapTileLayer
|
||||
{
|
||||
TileSource = new TileSource { UriFormat = "https://tile.opentopomap.org/{z}/{x}/{y}.png" },
|
||||
SourceName = "OpenTopoMap",
|
||||
Description = "© [OpenTopoMap](https://opentopomap.org/) © [OpenStreetMap contributors](http://www.openstreetmap.org/copyright)",
|
||||
MaxZoomLevel = 17
|
||||
}
|
||||
},
|
||||
{
|
||||
"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")
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public Dictionary<string, UIElement> MapOverlays { get; } = new Dictionary<string, UIElement>
|
||||
{
|
||||
{
|
||||
"Sample Image",
|
||||
new Image()
|
||||
},
|
||||
{
|
||||
"Seamarks",
|
||||
new MapTileLayer
|
||||
{
|
||||
TileSource = new TileSource { UriFormat = "http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png" },
|
||||
SourceName = "OpenSeaMap",
|
||||
MinZoomLevel = 9,
|
||||
MaxZoomLevel = 18
|
||||
}
|
||||
},
|
||||
{
|
||||
"Graticule",
|
||||
new MapGraticule
|
||||
{
|
||||
Opacity = 0.75
|
||||
}
|
||||
},
|
||||
{
|
||||
"Scale",
|
||||
new MapScale
|
||||
{
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
VerticalAlignment = VerticalAlignment.Bottom
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public MapViewModel()
|
||||
{
|
||||
// Add Bing Maps TileLayers with tile URLs retrieved from the Imagery Metadata Service
|
||||
// (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
|
||||
// for using these layers and must be assigned to the static BingMapsTileLayer.ApiKey property.
|
||||
|
||||
if (!string.IsNullOrEmpty(BingMapsTileLayer.ApiKey))
|
||||
{
|
||||
MapLayers.Add(
|
||||
"Bing Maps Road",
|
||||
new BingMapsTileLayer
|
||||
{
|
||||
Mode = BingMapsTileLayer.MapMode.Road,
|
||||
SourceName = "Bing Maps Road",
|
||||
Description = "© [Microsoft](http://www.bing.com/maps/)"
|
||||
});
|
||||
|
||||
MapLayers.Add(
|
||||
"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)
|
||||
});
|
||||
|
||||
MapLayers.Add(
|
||||
"Bing Maps Aerial with Labels",
|
||||
new BingMapsTileLayer
|
||||
{
|
||||
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)
|
||||
});
|
||||
}
|
||||
|
||||
var sampleImage = (Image)MapOverlays["Sample Image"];
|
||||
#if WINUI || UWP
|
||||
sampleImage.Source = new BitmapImage(new Uri("ms-appx:///10_535_330.jpg"));
|
||||
#else
|
||||
sampleImage.Source = new BitmapImage(new Uri("pack://siteoforigin:,,,/10_535_330.jpg"));
|
||||
#endif
|
||||
MapPanel.SetBoundingBox(sampleImage, new BoundingBox(53.54031, 8.08594, 53.74871, 8.43750));
|
||||
|
||||
Points.Add(new PointItem
|
||||
{
|
||||
Name = "Steinbake Leitdamm",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue