0

I'm trying to get map layers working in my Windows 8.1 app, which is using the Bing Maps SDK. Following microsoft's documentation, I created this code, and it doesn't seem to be working. No errors are thrown, making this problem even more confusing.

MapTileLayer tileLayer = new MapTileLayer();
tileLayer.TileSource = string.Format("http://mesonet.agron.iastate.edu/cache/tile.py/1.0.0/nexrad-n0q-900913/{{zoomLevel}}/{{x}}/{{y}}.png?{0}", DateTime.Now.ToString());
rMap.TileLayers.Add(tileLayer);

The URI variables zoomLevel,x, and y represent where to load the tile. 0 is the subdomain (This code was ported from Windows Phone 8, where it works fine

Kevin
  • 383
  • 2
  • 11

1 Answers1

0

The Windows Phone 8 and Windows 8 are not the same control at all as for WP8 it's provided by Here and on Win8 it's provided by Microsoft.

Anyway, you can do what you want by using the following code:

    /// <summary>
    /// Invoked when this page is about to be displayed in a Frame.
    /// </summary>
    /// <param name="e">Event data that describes how this page was reached.  The Parameter
    /// property is typically used to configure the page.</param>
    protected override async void OnNavigatedTo(NavigationEventArgs e)
    {
        Bing.Maps.MapTileLayer layer = new Bing.Maps.MapTileLayer();
        layer.GetTileUri += layer_GetTileUri;
        this.map.TileLayers.Add(layer);
    }

    private async void layer_GetTileUri(object sender, Bing.Maps.GetTileUriEventArgs e)
    {
        e.Uri = this.ComposeMyCustomUri(e);
    }

You will find e is a specific parameter object of type GetTileUriEventArgs, see:

http://msdn.microsoft.com/en-us/library/jj672952.aspx

Nicolas Boonaert
  • 2,954
  • 1
  • 20
  • 28