2017-06-25 23:05:48 +02:00
|
|
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
2020-01-09 19:40:10 +01:00
|
|
|
|
// © 2020 Clemens Fischer
|
2014-10-19 21:50:23 +02:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
2017-08-04 21:38:58 +02:00
|
|
|
|
public class BingMapsTileSource : TileSource
|
2014-10-19 21:50:23 +02:00
|
|
|
|
{
|
|
|
|
|
|
public override Uri GetUri(int x, int y, int zoomLevel)
|
|
|
|
|
|
{
|
2020-10-23 23:35:48 +02:00
|
|
|
|
Uri uri = null;
|
|
|
|
|
|
|
|
|
|
|
|
if (UriFormat != null && Subdomains != null && Subdomains.Length > 0 && zoomLevel > 0)
|
2014-10-19 21:50:23 +02:00
|
|
|
|
{
|
2020-10-23 23:35:48 +02:00
|
|
|
|
var subdomain = Subdomains[(x + y) % Subdomains.Length];
|
|
|
|
|
|
var quadkey = new char[zoomLevel];
|
2014-10-19 21:50:23 +02:00
|
|
|
|
|
2020-10-23 23:35:48 +02:00
|
|
|
|
for (var z = zoomLevel - 1; z >= 0; z--, x /= 2, y /= 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
quadkey[z] = (char)('0' + 2 * (y % 2) + (x % 2));
|
|
|
|
|
|
}
|
2014-10-19 21:50:23 +02:00
|
|
|
|
|
2020-10-23 23:35:48 +02:00
|
|
|
|
uri = new Uri(UriFormat
|
|
|
|
|
|
.Replace("{subdomain}", subdomain)
|
|
|
|
|
|
.Replace("{quadkey}", new string(quadkey)));
|
2014-10-19 21:50:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-10-23 23:35:48 +02:00
|
|
|
|
return uri;
|
2014-10-19 21:50:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|