Xamarin Forms Maps - Downloading and loading custom tiles from SQLite database

227 Views Asked by At

I am attempting to download a number of images to use as custom tiles for Google Maps. I am downloading the tiles as a byte[] using the code:

 using (WebClient webClient = new WebClient())
 {
     var response = webClient.DownloadData(new Uri(url));
     return response;
 }

Then I save the byte[] directly to my SQLite database:

TileData t = new TileData();
t.X = x;
t.Y = y;
t.Zoom = zoom;
t.Data = byteData;

conn.Insert(t);

Finally, in my custom TileProvider class in the overrided GetTile method, I create a tile using the byte[] saved in the SQLite db:

public Tile GetTile(int x, int y, int zoom)
{
   byte[] bitmap = RetreiveImage(x, y, zoom);

   Tile tile = new Tile(_width, _height, bitmap);

   return tile;
}

My problem is, when tiles are retrieved for overlay, I get the error:
"[skia] failed to create image decoder with message 'unimplemented'"

I have been struggling to figure out what is wrong. I assume my byte[] is in an invalid format but I do not know why.

The images I am downloading are .jfif, although from what I can tell .jfif is the same as .jpeg so it shouldnt be a problem.

0

There are 0 best solutions below