-1

I want to get map box tiles from database but it does not work. I get MBTilesMapProvider class from here. It is invoked like below:

map.Manager.Mode = AccessMode.ServerAndCache;
map.MapProvider = new  MBTilesMapProvider("C:\\Users\\NPC\\Desktop\\test\\ne.mbtiles");

result: [2]: https://i.stack.imgur.com/rGRCP.png

but if google maps used as map provider like below it works well

map.Manager.Mode = AccessMode.ServerAndCache;
map.MapProvider = GoogleSatelliteMapProvider.Instance;

When i debuged i noticed that GetTiles method is invoked never.

Note: I think there is no problem about finding database because it reads meta data from database.

  • GetTiles() returns an image (see : https://github.com/geobabbler/MBTilesMapProvider/blob/master/Helpers/MBTilesHelper.cs). So in c# you need a picturebox for the image. – jdweng Nov 25 '20 at 12:33
  • i think it is not the main problem when i debug i noticed that GetTiles is invoked never. – KingOfTheLosers Nov 26 '20 at 06:36
  • You need an image so you can set a picturebox : pictureBox1.Image. What are you getting know? A byte array or a stream? You need to convert what you have to an image. – jdweng Nov 26 '20 at 07:30
  • i think gmap.net handles it automatically as i don't invoke GetTiles method explicitly. However, The real problem is mapbox tiles' x and y (row and column) are different than gmap tiles, as i understand. – KingOfTheLosers Nov 26 '20 at 08:41
  • Somehow gmap started to admit it cannot find files, even though i have not changed anything. – KingOfTheLosers Nov 26 '20 at 08:44
  • Here is Microsoft documentation. The Provider is a webcontrol with each tile a different html document : https://learn.microsoft.com/en-us/aspnet/web-forms/overview/data-access/database-driven-site-maps/building-a-custom-database-driven-site-map-provider-cs – jdweng Nov 26 '20 at 13:25

1 Answers1

-1

I solved solution by make a bit changes at MBTilesHelper.cs.

First i realized that when reading metadata from database MinZoom and MaxZoom values, they always stay as zero because it does not contain MinZoom or MaxZoom. Therefore, i set them manually.

and secondly i changed a bit "getImage" method.

private PureImage getImage(GPoint pos, int zoom)
{
    PureImage retval = null;

    var resultImage = _mbtiles.GetTileStream(pos.X, pos.Y, zoom);
        
    if (resultImage != null && resultImage.Length > 0)
    {
        //resultImage.Position = 0L;
        retval = GetTileImageFromArray(resultImage);
    }
    return retval;
}