2010-12-08 58 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));

是顯示圖像...