Bing Maps Layers in sample applications

This commit is contained in:
ClemensFischer 2024-06-30 16:21:36 +02:00
parent 08a7888748
commit a02abb7f76
7 changed files with 88 additions and 211 deletions

View file

@ -1,7 +1,7 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="SampleApplication.App"
RequestedThemeVariant="Default">
RequestedThemeVariant="Light">
<Application.Styles>
<FluentTheme />
<StyleInclude Source="avares://MapControl.Avalonia/Themes/Generic.axaml"/>

View file

@ -1,11 +1,7 @@
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Media;
using MapControl;
using MapControl.UiTools;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace SampleApplication
@ -15,63 +11,17 @@ namespace SampleApplication
static MainWindow()
{
//TileImageLoader.Cache = new MapControl.Caching.ImageFileCache(TileImageLoader.DefaultCacheFolder);
var bingMapsApiKeyPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MapControl", "BingMapsApiKey.txt");
if (File.Exists(bingMapsApiKeyPath))
{
BingMapsTileLayer.ApiKey = File.ReadAllText(bingMapsApiKeyPath)?.Trim();
}
}
public MainWindow()
{
InitializeComponent();
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 = Brushes.White,
MapBackground = Brushes.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 = Brushes.White,
MapBackground = Brushes.Black
}
});
}
AddBingMapsLayers();
AddTestLayers();
}
partial void AddBingMapsLayers();
partial void AddTestLayers();
private void MapItemsControlSelectionChanged(object sender, SelectionChangedEventArgs e)