This project has moved. For the latest updates, please go here.

How to load my local tile files in ajax map control?

Topics: SharpMap Project, SharpMap v0.9 / v1.x, Web Controls
Nov 16, 2012 at 7:27 PM

Hi everyone:

I have got some osm tile files from openstreetmap,and then created a virtual directory for store and release the tile files, for example:  http://localhost/ImageData. 

and then I want to load my tile files from my Virtual directory in the ajax map control,so I created a custom OsmTileServerConfig  ,a custom OsmRequest and a custom OsmTileSource using the Brutile lib,a  TileAsyncLayer,and added the layer to my ajax map,but  the map does not load successfully,I can not see any tile in my ajax map website.what's the reason? Thanks!

my tile file virtual directory is like this:


this is my code:

//Create a custom osm TileRequst using my custom //OsmTileServerConfig
var tileRequest = new BruTile.Web.OsmRequest(new BruTile.Web.OsmTileServerConfig("http://{0}localhost/ImageData/{1}/{2}/{3}.png ", 1, new[] { "" }, 0, 11));
//Create a  custom OsmTileSource
var tileSource = new BruTile.Web.OsmTileSource(tileRequest);
//Create a SharpMap TileAsynLayer
TileAsyncLayer tileLayer = new SharpMap.Layers.TileAsyncLayer(new BruTile.Web.OsmTileSource(), "OSM", Color.Red, true);
//Add the layer to my ajax map

Nov 19, 2012 at 5:54 AM

I think the problem is that you use TileLayerAsync. This is a "special" layer that is designed to work with the Windows.Forms' MapBox control.

Another thing that comes to my mind is, if you already have all the tiles on your machine, why don't you use the FileTileProvider?

Hth FObermaier

Nov 19, 2012 at 1:51 PM

Thanks  FObermaier.  When I used the TileLayer instead of TileAsyncLayer , the ajax map displayed successfully,and I can see my map, but I have a question, in this case,I find  that server returns whole picture to the client,not many tiles,so the map displays so slow, How should I do to return many tiles like the Windows.Forms' MapBox control with  TileAsyncLayer ?

I  used the OsmRequest instead of FileTileProvider,because my tile files are made from OpenStreetMap file, so I used the OsmRequest not FileTileProvider.



Nov 20, 2012 at 7:22 PM

For web context's the suggested approach is to use OpenLayers et. al. and SharpMap as a WMS server.

See the SharpMap.Demo.Wms project

Hth FObermaier

Nov 21, 2012 at 2:26 PM

OK Thanks!  FObermaier!