Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Phone 7 Map Control with custom layer in offline mode

Hi WP7 mobile passionate developers!

I'm trying to use the default provided Bing Map control from Windows Phone controls. Specifically I'm trying to use a custom TileSource to provide a custom made tiled map that will be stored in the project as a folder (Content files) or in isolate storage.

Down I present the custom class I try to use with map tiles/images stored in "map" folder in ZXY storage format as content files.

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

Trying to use this is not working and custom tiles are not shown although no error is thrown. Does anyone tried to use windows phone map control this way? If that's not the right approach which one is? Any workaround?

Thank you in advance!

Claudiu

like image 755
Claudiu Farcas Avatar asked Dec 08 '10 10:12

Claudiu Farcas


3 Answers

Have you set the Build Action on your image(s) to Content?

like image 122
Matt Lacey Avatar answered Sep 30 '22 21:09

Matt Lacey


The Exception is:

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)

How to get an image from IsolatedStorage, Ressource or MediaLibrary with UriKind.Absolute i not already found out ...maybe you know?

like image 39
sapshan Avatar answered Sep 30 '22 21:09

sapshan


This seems to be quite a FAQ problem - Map Tile Caching for Offline Viewing - shame there isn't an FAQ solution :/

like image 45
Stuart Avatar answered Sep 30 '22 22:09

Stuart