Once a GeoPackage instance is connected, you can access tile tables. Use getTileTables to list tables and getTileDaoWithTableName to get a Data Access Object (DAO) for a specific table. With the DAO, you can use GeoPackageTileRetriever to draw tiles directly onto an HTML5 Canvas or retrieve them as Base64 data URLs.
// get the tile table names
geopackage.getTileTables(function(err, tileTableNames) {
// get the info for the first table
geoPackage.getTileDaoWithTableName(tileTableNames[0], function(err, tileDao) {
// draw a tile into a canvas for an XYZ tile
var canvas = canvasFromSomewhere;
var gpr = new GeoPackageTileRetriever(tileDao, 256, 256);
var x = 0;
var y = 0;
var zoom = 0;
gpr.drawTileIn(x, y, zoom, canvas, function() {
console.log('Tile drawn');
});
// or get a tile base64 data URL for an XYZ tile
gpr.getTile(x, y, zoom, function(err, tileBase64DataURL) {
console.log('got the base64 data url');
});
});
});