2010-12-08 60 views
7

嗨WP7手机激情开发者!Windows Phone 7地图控制与离线模式下的自定义图层

我正尝试使用Windows Phone控件提供的默认Bing Map控件。 具体而言,我试图使用自定义TileSource来提供自定义的平铺地图,该地图将作为文件夹(内容文件)存储在项目中或隔离存储中。

向下我将ZXY存储格式中存储在“地图”文件夹中的地图图块/图像作为内容文件提供给我使用的自定义类。

public class CustomTileSource : Microsoft.Phone.Controls.Maps.TileSource 
{ 

    private string uriFormat = @"map/{0}/{1}/{2}.png"; 
    public string UriFormat 
    { 
     get { return uriFormat; } 
     set { uriFormat = value; } 
    } 

    public override Uri GetUri(int x, int y, int zoomLevel) 
    { 
     var url = string.Format(UriFormat, zoomLevel, x, y); 
     return new Uri(url, UriKind.Relative); 
    } 
} 

试图使用这不工作和自定义瓷砖不显示,虽然没有错误引发。 有没有人试过用这种方式使用windows phone map control? 如果这不是一个正确的方法?任何解决方法?

预先感谢您!

克劳迪乌

+0

嘿#wp7爱好者..请为此功能投票 - http://位。ly/offlinebingmapcontrol !!! – 2011-04-14 20:34:09

+0

您还可以投票支持:[为Bing地图控制启用脱机存储](http://wpdev.uservoice.com/forums/110705-app-platform/suggestions/1761329-enable-offline-storage-for-bing-maps - 控制) – 2012-03-03 19:03:30

回答

2

是否已经设置生成操作图像(S)来Content吗?

+0

是的..所有图像添加到项目已设置“构建行动”为“内容” – 2010-12-08 13:00:47

2

唯一的例外是:

This operation is not supported on a relative URI. 
    at System.Uri.get_AbsoluteUri() 
    at System.Windows.Media.MultiScaleTileSource.GetTileLayerUrl(IntPtr nativeTarget, Int32 tileLevel, Int32 tileX, Int32 tileY, Int32 uTileImageIndex, IntPtr& fullTileUri, UInt32& fullTileUriLength) 

如何从IsolatedStorage,或的ressource与MediaLibrary的UriKind.Absolute图像我不是已经发现了 ...也许你知道吗?

+0

我们通过创建我们自己的映射控制结束... – 2011-02-10 08:18:04

1

我试过,

你尝试构建使用的应用程序ID。在这个问题描述一个绝对的文件网址?用于脱机查看地图图块缓存

地图组件不显示我的图像,但简单

Image.Source =新的BitmapImage(新的URI(“文件:///应用程序/安装/ 0277CC52-888B- 4593-A28D-4CFF818E81E7/Install/maps/-1040122162.jpg“,UriKind.Absolute));

是显示图像...