mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-04 14:08:32 +00:00
Reworked sample applications
This commit is contained in:
parent
e2f4fc13b1
commit
1d1b2942b4
9 changed files with 468 additions and 283 deletions
|
|
@ -1,9 +1,11 @@
|
|||
using MapControl;
|
||||
using MapControl.Caching;
|
||||
using MapControl.UiTools;
|
||||
using Microsoft.UI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -14,23 +16,19 @@ namespace SampleApplication
|
|||
{
|
||||
static MainWindow()
|
||||
{
|
||||
try
|
||||
ImageLoader.HttpClient.DefaultRequestHeaders.Add("User-Agent", "XAML Map Control Test Application");
|
||||
|
||||
TileImageLoader.Cache = new ImageFileCache(TileImageLoader.DefaultCacheFolder);
|
||||
//TileImageLoader.Cache = new FileDbCache(TileImageLoader.DefaultCacheFolder);
|
||||
//TileImageLoader.Cache = new SQLiteCache(TileImageLoader.DefaultCacheFolder);
|
||||
|
||||
var bingMapsApiKeyPath = Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MapControl", "BingMapsApiKey.txt");
|
||||
|
||||
if (File.Exists(bingMapsApiKeyPath))
|
||||
{
|
||||
ImageLoader.HttpClient.DefaultRequestHeaders.Add("User-Agent", "XAML Map Control Test Application");
|
||||
|
||||
TileImageLoader.Cache = new ImageFileCache(TileImageLoader.DefaultCacheFolder);
|
||||
//TileImageLoader.Cache = new FileDbCache(TileImageLoader.DefaultCacheFolder);
|
||||
//TileImageLoader.Cache = new SQLiteCache(TileImageLoader.DefaultCacheFolder);
|
||||
|
||||
var bingMapsApiKeyPath = Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MapControl", "BingMapsApiKey.txt");
|
||||
|
||||
BingMapsTileLayer.ApiKey = File.ReadAllText(bingMapsApiKeyPath)?.Trim();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public MainWindow()
|
||||
|
|
@ -39,12 +37,56 @@ namespace SampleApplication
|
|||
|
||||
Title = "XAML Map Control - WinUI Sample Application";
|
||||
|
||||
if (!string.IsNullOrEmpty(BingMapsTileLayer.ApiKey))
|
||||
{
|
||||
mapLayersMenuButton.MapLayers.Add(new MapLayerItem
|
||||
{
|
||||
Text = "Bing Maps Road",
|
||||
Layer = new BingMapsTileLayer
|
||||
{
|
||||
Mode = BingMapsTileLayer.MapMode.Road,
|
||||
SourceName = "Bing Maps Road",
|
||||
Description = "© [Microsoft](http://www.bing.com/maps/)"
|
||||
}
|
||||
});
|
||||
|
||||
mapLayersMenuButton.MapLayers.Add(new MapLayerItem
|
||||
{
|
||||
Text = "Bing Maps Aerial",
|
||||
Layer = 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)
|
||||
}
|
||||
});
|
||||
|
||||
mapLayersMenuButton.MapLayers.Add(new MapLayerItem
|
||||
{
|
||||
Text = "Bing Maps Aerial with Labels",
|
||||
Layer = 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)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
AddChartServerLayer();
|
||||
|
||||
if (TileImageLoader.Cache is ImageFileCache)
|
||||
{
|
||||
Activated += WindowActivated;
|
||||
}
|
||||
}
|
||||
|
||||
partial void AddChartServerLayer();
|
||||
|
||||
private async void WindowActivated(object sender, WindowActivatedEventArgs e)
|
||||
{
|
||||
Activated -= WindowActivated;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue