将Maptiles加载到BingMap silverlight控件中 [英] Loading maptiles into a BingMap silverlight control
问题描述
我是Windows Phone开发的新手,我目前正在为一家想要使用自己的地图(构建maptiles)的公司构建应用程序.我想在解决方案中使用BingMap silverlight控件.我的问题是:这真的可能吗?我试图通过像这样从MapTiles类继承来覆盖"GetUri"方法;
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;
}
}
是否可以在没有HTTP请求的情况下加载maptile?
Is it possible to load the maptiles without a HTTP request ?
非常感谢
Nroblex
推荐答案
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
在开发过程中,您可以尝试WAMP( http://www.wampserver.com/en/),然后从本地主机提供图块:
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));
}
此处介绍了TileToQuadkey方法: http://msdn.microsoft.com/en-us/library/bb259689.aspx
The TileToQuadkey method is described here: http://msdn.microsoft.com/en-us/library/bb259689.aspx
但是对于生产而言,您将需要用自己的Web服务器替换WAMP.
But for production you will need to replace WAMP with your own web server.
这篇关于将Maptiles加载到BingMap silverlight控件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!