mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-01-23 17:10:25 +01:00
Bing Maps Layers in sample applications
This commit is contained in:
parent
08a7888748
commit
a02abb7f76
|
|
@ -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"/>
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
76
SampleApps/Shared/BingMapsLayers.cs
Normal file
76
SampleApps/Shared/BingMapsLayers.cs
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using MapControl;
|
||||
using MapControl.UiTools;
|
||||
#if WPF
|
||||
using System.Windows.Media;
|
||||
#elif WINUI
|
||||
using Microsoft.UI;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
#elif UWP
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml.Media;
|
||||
#elif AVALONIA
|
||||
using Avalonia.Media;
|
||||
#endif
|
||||
|
||||
namespace SampleApplication
|
||||
{
|
||||
#if UWP
|
||||
public partial class MainPage
|
||||
#else
|
||||
public partial class MainWindow
|
||||
#endif
|
||||
{
|
||||
partial void AddBingMapsLayers()
|
||||
{
|
||||
#if UWP
|
||||
var bingMapsApiKeyPath = "BingMapsApiKey.txt";
|
||||
#else
|
||||
var bingMapsApiKeyPath = Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MapControl", "BingMapsApiKey.txt");
|
||||
#endif
|
||||
if (File.Exists(bingMapsApiKeyPath))
|
||||
{
|
||||
BingMapsTileLayer.ApiKey = File.ReadAllText(bingMapsApiKeyPath)?.Trim();
|
||||
|
||||
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)
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,17 +1,13 @@
|
|||
using MapControl;
|
||||
using MapControl.UiTools;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Windows.Devices.Input;
|
||||
using Windows.System;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
namespace SampleApplication
|
||||
{
|
||||
|
|
@ -20,64 +16,17 @@ namespace SampleApplication
|
|||
static MainPage()
|
||||
{
|
||||
//TileImageLoader.Cache = new MapControl.Caching.ImageFileCache(TileImageLoader.DefaultCacheFolder);
|
||||
//TileImageLoader.Cache = new MapControl.Caching.FileDbCache(TileImageLoader.DefaultCacheFolder);
|
||||
//TileImageLoader.Cache = new MapControl.Caching.SQLiteCache(TileImageLoader.DefaultCacheFolder);
|
||||
|
||||
var bingMapsApiKeyPath = "BingMapsApiKey.txt";
|
||||
|
||||
if (File.Exists(bingMapsApiKeyPath))
|
||||
{
|
||||
BingMapsTileLayer.ApiKey = File.ReadAllText(bingMapsApiKeyPath)?.Trim();
|
||||
}
|
||||
}
|
||||
|
||||
public MainPage()
|
||||
{
|
||||
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 = 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)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
AddBingMapsLayers();
|
||||
AddTestLayers();
|
||||
}
|
||||
|
||||
partial void AddBingMapsLayers();
|
||||
partial void AddTestLayers();
|
||||
|
||||
private void MapItemsControlSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@
|
|||
<EnableGatekeeperAnalysis>false</EnableGatekeeperAnalysis>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Shared\BingMapsLayers.cs">
|
||||
<Link>BingMapsLayers.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\HyperlinkText.cs">
|
||||
<Link>HyperlinkText.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
|||
|
|
@ -1,15 +1,11 @@
|
|||
using MapControl;
|
||||
using MapControl.UiTools;
|
||||
using Microsoft.UI;
|
||||
using Microsoft.UI.Input;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Windows.System;
|
||||
|
||||
|
|
@ -20,16 +16,6 @@ namespace SampleApplication
|
|||
static MainWindow()
|
||||
{
|
||||
//TileImageLoader.Cache = new MapControl.Caching.ImageFileCache(TileImageLoader.DefaultCacheFolder);
|
||||
//TileImageLoader.Cache = new MapControl.Caching.FileDbCache(TileImageLoader.DefaultCacheFolder);
|
||||
//TileImageLoader.Cache = new MapControl.Caching.SQLiteCache(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()
|
||||
|
|
@ -38,49 +24,11 @@ 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)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
AddBingMapsLayers();
|
||||
AddTestLayers();
|
||||
}
|
||||
|
||||
partial void AddBingMapsLayers();
|
||||
partial void AddTestLayers();
|
||||
|
||||
private void MapItemsControlSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
using MapControl;
|
||||
using MapControl.UiTools;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace SampleApplication
|
||||
{
|
||||
|
|
@ -24,63 +21,17 @@ namespace SampleApplication
|
|||
// Configuration = "T400:6379",
|
||||
// InstanceName = "MapTileCache/"
|
||||
//}));
|
||||
|
||||
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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue