Loading maptiles into a BingMap silverlight control

大憨熊 提交于 2019-12-11 10:27:42

问题


I am new to Windows Phone development and I am currently building an application for a company that want to use its own map (build up of maptiles). I want to use the BingMap silverlight control in the solution. My question is: Is this really possible? I have tried to override the "GetUri" method by inherit from the MapTiles class like this;

public class MyTiles : Microsoft.Phone.Controls.Maps.TileSource
{
    public override Uri GetUri(int x, int y, int zoomLevel)
    {
        if (zoomLevel > 0)
        {
            var Url = string.Format(UriFormat, Server, MapMode, zoomLevel, x, y);
            return new Uri(Url);
        }
        return null;
    }
}

Is it possible to load the maptiles without a HTTP request ?

Many thanks in advance

Nroblex


回答1:


Unfortunately the only way is to host the tiles over the internet: http://social.msdn.microsoft.com/Forums/en-US/94c2d9bc-f1a7-4201-9e5a-4d6a47d285cb/maptilelayer-with-local-tiles?forum=bingmapswindows8

Whilst in development you could try WAMP (http://www.wampserver.com/en/) and then serve the tiles from localhost:

MapTileLayer tileLayer = new MapTileLayer();
tileLayer.GetTileUri += tileLayer_GetTileUri;

private void tileLayer_GetTileUri(object sender, GetTileUriEventArgs e)
{
    string quadkey = TileToQuadkey(e.X, e.Y, e.LevelOfDetail);
    e.Uri = new Uri(String.Format("http://localhost/tiles/{0}.png", quadkey));
}

The TileToQuadkey method is described here: http://msdn.microsoft.com/en-us/library/bb259689.aspx

But for production you will need to replace WAMP with your own web server.



来源:https://stackoverflow.com/questions/10316784/loading-maptiles-into-a-bingmap-silverlight-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!