2014-10-03 95 views
0

我试图让地图图层在我的Windows 8.1应用中使用Bing Maps SDK工作。遵循微软的文档,我创建了这个代码,它似乎没有工作。没有错误发生,使这个问题更加混乱。Bing地图SDK Win8.1 - 添加图层

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); 

的URI变量zoomLevelx,并y表示要加载瓦片。 0是子域(此代码已从Windows Phone 8移植到其中,它可以正常工作

回答

0

Windows Phone 8和Windows 8与Windows 8提供的WP8不同,它由Microsoft和Windows提供。

无论如何,你可以做你想做的使用下面的代码:

/// <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); 
    } 

你会发现eGetTileUriEventArgs类型的特定参数对象,请参见:

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