mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-06 06:55:04 +00:00
Version 4: Upgrade to VS 2017
This commit is contained in:
parent
2aafe32e00
commit
ec47f225b3
142 changed files with 1828 additions and 18384 deletions
39
MapControl/Shared/BingMapsTileSource.cs
Normal file
39
MapControl/Shared/BingMapsTileSource.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// © 2017 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
public class BingMapsTileSource : TileSource
|
||||
{
|
||||
private readonly string[] subdomains;
|
||||
|
||||
public BingMapsTileSource(string uriFormat, string[] subdomains)
|
||||
: base(uriFormat)
|
||||
{
|
||||
this.subdomains = subdomains;
|
||||
}
|
||||
|
||||
public override Uri GetUri(int x, int y, int zoomLevel)
|
||||
{
|
||||
if (zoomLevel < 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var subdomain = subdomains[(x + y) % subdomains.Length];
|
||||
var quadkey = new char[zoomLevel];
|
||||
|
||||
for (var z = zoomLevel - 1; z >= 0; z--, x /= 2, y /= 2)
|
||||
{
|
||||
quadkey[z] = (char)('0' + 2 * (y % 2) + (x % 2));
|
||||
}
|
||||
|
||||
return new Uri(UriFormat
|
||||
.Replace("{subdomain}", subdomain)
|
||||
.Replace("{quadkey}", new string(quadkey)));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue