mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-03-29 00:26:19 +01:00
Bing Maps Key from file
This commit is contained in:
parent
3d93a14eb0
commit
8aed92638f
|
|
@ -163,8 +163,6 @@ namespace ViewModel
|
||||||
// A Bing Maps API Key (http://msdn.microsoft.com/en-us/library/ff428642.aspx) is required
|
// 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.
|
// for using these layers and must be assigned to the static BingMapsTileLayer.ApiKey property.
|
||||||
|
|
||||||
//BingMapsTileLayer.ApiKey = "...";
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(BingMapsTileLayer.ApiKey))
|
if (!string.IsNullOrEmpty(BingMapsTileLayer.ApiKey))
|
||||||
{
|
{
|
||||||
MapLayerNames.Add("Bing Maps Road");
|
MapLayerNames.Add("Bing Maps Road");
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,49 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using MapControl;
|
using MapControl;
|
||||||
|
using MapControl.Caching;
|
||||||
using ViewModel;
|
using ViewModel;
|
||||||
|
|
||||||
namespace WpfApplication
|
namespace WpfApplication
|
||||||
{
|
{
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
|
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);
|
||||||
|
//TileImageLoader.Cache = null;
|
||||||
|
|
||||||
|
BingMapsTileLayer.ApiKey = File.ReadAllText(@"..\..\..\BingMapsApiKey.txt")?.Trim();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.WriteLine(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
ImageLoader.HttpClient.DefaultRequestHeaders.Add("User-Agent", "XAML Map Control Test Application");
|
|
||||||
var cache = new MapControl.Caching.ImageFileCache(TileImageLoader.DefaultCacheFolder);
|
|
||||||
TileImageLoader.Cache = cache;
|
|
||||||
//TileImageLoader.Cache = new MapControl.Caching.FileDbCache(TileImageLoader.DefaultCacheFolder);
|
|
||||||
//TileImageLoader.Cache = new MapControl.Caching.SQLiteCache(TileImageLoader.DefaultCacheFolder);
|
|
||||||
//TileImageLoader.Cache = null;
|
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Loaded += async (s, e) =>
|
if (TileImageLoader.Cache is ImageFileCache cache)
|
||||||
{
|
{
|
||||||
await Task.Delay(2000);
|
Loaded += async (s, e) =>
|
||||||
await cache.Clean();
|
{
|
||||||
};
|
await Task.Delay(2000);
|
||||||
|
await cache.Clean();
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MapMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
private void MapMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue