This project is read-only.

Using offline OpenStreetMap with MapWinGis in a C# Application

Jul 25, 2016 at 5:51 PM
Hi there,

i try to use mapServer as TileServer on an Apatche server (ms4w) to access offline osm maps.
The access via Browser still works, but when i try to get the Tiles from the C# application no Tiles are displayed.

Here is the code:
axMap1.Projection = tkMapProjection.PROJECTION_GOOGLE_MERCATOR;
axMap1.ZoomBehavior = tkZoomBehavior.zbUseTileLevels;

TileProviders providers = axMap1.Tiles.Providers;
int providerId = (int)tkTileProvider.ProviderCustom +1;

//bool tmp = providers.Add(providerId, "Custom TMS provider", "http://localhost/cgi-bin/mapserv.exe?map=D:/ms4w/apps/osm/basemaps/osm-google.map&mode=tile&layers=all&tilemode=gmap&tile={x}+{y}+{zoom}.png", tkTileProjection.SphericalMercator, 0, 17);
bool tmp = providers.Add(providerId, "Custom TMS provider", "http://tile.openstreetmap.org/{zoom}/{x}/{y}.png", tkTileProjection.SphericalMercator, 0, 17);
//bool tmp = providers.Add(providerId, "Custom TMS provider", "file:///d:/ms4w/Apache/htdocs/maps/{zoom}/{x}/{y}.png", tkTileProjection.SphericalMercator, 0, 17);

//Check if provider was added
if (tmp == false)
{
    Console.WriteLine(providers.LastErrorCode.ToString());
}

var ut = new Utils();
tkTileProjection pr = axMap1.Tiles.ServerProjection;
GeoProjection gp = ut.TileProjectionToGeoProjection(pr);
axMap1.GeoProjection = gp;
Only when i use openstreetmaps as custom provider everything works fine.
The other urls are accepted by the add method of TileProviders.

(I used the following Tutorial to get the MapServer https://github.com/mapserver/mapserver/wiki/RenderingOsmDataWindows)

Can enybody help me
Sep 27, 2016 at 2:49 PM
Sorry for the late response.

I think the problem is with file:///d:
Don't you have a localhost url you can use?

Regards,
Paul
Sep 28, 2016 at 7:13 AM
Hi,
at first thanks for the response.

As you can see in the top i try 3 different ways to get the tiles.

first case:

bool tmp = providers.Add(providerId, "Custom TMS provider", "http://localhost/cgi-bin/mapserv.exe?map=D:/ms4w/apps/osm/basemaps/osm-google.map&mode=tile&layers=all&tilemode=gmap&tile={x}+{y}+{zoom}.png", tkTileProjection.SphericalMercator, 0, 17);
here i try to get the tiles via the mapserv.exe running on my localhost Apache server. (doesnt work)

second case:

bool tmp = providers.Add(providerId, "Custom TMS provider", "http://tile.openstreetmap.org/{zoom}/{x}/{y}.png", tkTileProjection.SphericalMercator, 0, 17);
here i try to get the tiles via openstreetmap.org directly from the internet. (works fine)

And in the 3rd case:

bool tmp = providers.Add(providerId, "Custom TMS provider", "file:///d:/ms4w/Apache/htdocs/maps/{zoom}/{x}/{y}.png", tkTileProjection.SphericalMercator, 0, 17);
here i try to get the tiles from the localhost Apache via file access. (doesnt work)