Skip to content

Latest commit

 

History

406 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NPM version Build Status Dependency Status

mbtiles

This is a fork of @mapbox/mbtiles.

It only provides sync and read-only subset of API. It is using node:sqlite instead of sqllite3.

Installation

npm install @mapwhit/mbtiles
import MBTiles from '@mapwhit/mbtiles';

Environment Variables

This library uses the MBTILES_PRAGMA environment variable to control SQLite pragmas. Set this variable to customize SQLite behavior, for example:

MBTILES_PRAGMA="PRAGMA journal_mode = WAL; PRAGMA synchronous = NORMAL;"

API

Constructor

All MBTiles instances need to be constructed before any of the methods become available. NOTE: All methods described below assume you've taken this step.

const mbtiles = new MBTiles('./path/to/file.mbtiles');
console.log(mbtiles) // mbtiles object with methods listed below

Reading

getTile(z, x, y)

Get an individual tile from the MBTiles table. This can be a raster or gzipped vector tile. Also returns headers that are important for serving over HTTP.

const { error, tile, headers } = mbtiles.getTile(z, x, y);
// `tile` is your gzipped buffer - use zlib to gunzip or inflate

getInfo()

Get info of an MBTiles file, which is stored in the metadata table. Includes information like zoom levels, bounds, vector_layers, that were created during generation. This performs fallback queries if certain keys like bounds, minzoom, or maxzoom have not been provided.

const info = mbtiles.getInfo();

Test

npm test

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages