Trying to add images (tiles) to a map

81 views Asked by At

Image of project structure: http://i.imgur.com/yHdZxA2.png

I'm quite sure that it is my link that doesn't work. I've tried:

"ms-appx:/TileImages/{0}/{1}/{2}", "ms-appx:///TileImages/{0}/{1}/{2}", "ms-appx:///Local/TileImages/{0}/{1}/{2}", "ms-appdata:///Local/TileImages/{0}/{1}/{2}", 

but nothing seems to work.

But when I try another link "http://tiles.kartat.kapsi.fi/peruskartta/{0}/{1}/{2}" it works.  

namespace BingMapsWindowsStoreApp
{

public sealed partial class MainPage: Page
{
private string MyLink = "ms-appx:/TileImages/{0}/{1}/{2}.png";
public MainPage()
{

this.InitializeComponent();
}
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
MapTileLayer layer = new MapTileLayer();
layer.GetTileUri += layer_GetTileUri;
this.myMap.TileLayers.Add(layer);
}
private async void layer_GetTileUri(object sender, GetTileUriEventArgs e)
{
e.Uri = this.CreateTileUri(e);
}
private Uri CreateTileUri(GetTileUriEventArgs e)
{
return new Uri(string.Format(MyLink, e.LevelOfDetail, e.X, e.Y));
}
}
}
1

There are 1 answers

0
Marcus Håkansson On

The MapTileLayer class in Bing Maps is designed to only access map tiles that are hosted online.