This project has moved and is read-only. For the latest updates, please go here.

Local Filepath

Jan 16, 2013 at 4:27 PM


thanks for this great project.

I've generated my own OSM tileset and I would like to use that tilecache from the local disk (there should be no server running). 

For some reason, I cannot seem to use a local filepath.

For example, serving from local host works fine:

TileSource="http://localhost:8182/jepp/{z}/{x}/{y}.png" MinZoomLevel="9" MaxZoomLevel="13"

However, the following two statements don't work:

TileSource="file://c:/jepp/{z}/{x}/{y}.png" MinZoomLevel="9" MaxZoomLevel="13"
TileSource="file://c/jepp/{z}/{x}/{y}.png" MinZoomLevel="9" MaxZoomLevel="13"

Is it possible to serve from filesystem without using a server?

Jan 16, 2013 at 5:35 PM

I guess I could extend the DownloadImage method in TileImageLoader.WPF.cs.

Jan 17, 2013 at 10:29 AM
Edited Jan 17, 2013 at 10:30 AM

Hi zeroc8,

I guess I will include this feature in the next MapControl release.

For now you could derive from class ImageTileSource like this:

public class LocalFileTileSource : ImageTileSource
    public override bool CanLoadAsync
        get { return true; }

    public override ImageSource LoadImage(int x, int y, int zoomLevel)
        BitmapImage image;

            image = new BitmapImage();
            image.CacheOption = BitmapCacheOption.OnLoad;
            image.UriSource = GetUri(x, y, zoomLevel);
            image = null;

        return image;

and use that in XAML like shown below. Note the 3 slashes in file:///.

<map:TileLayer SourceName="OSM Local" Description="© {y} OpenStreetMap Contributors, CC-BY-SA">
    <local:LocalFileTileSource UriFormat="file:///C:/jepp/{z}/{x}/{y}.png"/>


Jan 17, 2013 at 6:57 PM

Feature added in Version 1.1.5.

Jan 17, 2013 at 7:13 PM

Great, thank you, it works!