how to add map box tiles to gmap?

563 views Asked by At

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.

1

There are 1 answers

0
KingOfTheLosers On BEST ANSWER

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