Skip to content

Latest commit

 

History

History
246 lines (182 loc) · 7.24 KB

api.md

File metadata and controls

246 lines (182 loc) · 7.24 KB

Classes

ControlSaveTiles
TileLayerOffline

Functions

openDB()boolean

Open database 'leaflet-maps' from IndexedDB storage

setLayer(object)none

Set a baseLayer, also this Control and its baseLayer to have the same DB table

setTable(table)

Sets the current DB table for Control and its TileLayer

deleteTable(table)Promise.<void>

Delete a table from DB

putItem(table)Promise.<void>

Add/Update an item in DB table

getItem(table)Promise.<void>

Get an item in DB table

deleteItem(table)Promise.<void>

Delete an item in DB table

setZoomlevels(zoomlevels)

Set options zoomlevels

setBounds(bounds)

Set Lat/Lng bounds of map to save

setStorageSize(function)

Sets status.storagesize equal to count of table rows

saveMap()

Prepare zoom levels to download and activate callback function to save(async) all map tiles on table name confirmation. Fires event 'savestart'.

getTileUrls(zoom)Array.<object>

getTileUrls for single zoomlevel

Typedefs

ControlStatus : Object

Status of ControlSaveTiles, keeps info about process during downloading and saving tiles. Used internal and as object for events.

ControlSaveTiles

Kind: global class
Properties

Name Type Description
status ControlStatus
baseLayer TileLayerOffline TileLayer to control
dtable object DB table associated with baseLayer https://dexie.org/docs/Table/Table

new ControlSaveTiles()

Control to save tiles, invisible by default

Example

const controlSaveTiles = L.control.savetiles(myTileLayerOffline, {
  zoomlevels: [13, 16],   // optional zoomlevels to save, default current zoomlevel
  maxZoom: 17
});

TileLayerOffline

Kind: global class
Properties

Name Type Description
dtable object database table to get tiles from https://dexie.org/docs/Table/Table
offtest boolean simulate offline response or not

new TileLayerOffline()

A layer that uses IndexedDB store tiles when available. Falls back to online.

openDB() ⇒ boolean

Open database 'leaflet-maps' from IndexedDB storage

Kind: global function
Returns: boolean - result - false when not found or error

setLayer(object) ⇒ none

Set a baseLayer, also this Control and its baseLayer to have the same DB table

Kind: global function

Param Type Description
object TileLayerOffline TileLayerOffline

setTable(table)

Sets the current DB table for Control and its TileLayer

Kind: global function

Param Type Description
table string name

deleteTable(table) ⇒ Promise.<void>

Delete a table from DB

Kind: global function
Returns: Promise.<void> - fires event 'tblevent' to refresh table list

Param Type Description
table string name

putItem(table) ⇒ Promise.<void>

Add/Update an item in DB table

Kind: global function
Returns: Promise.<void> - operation result

Param Type Description
table string name

getItem(table) ⇒ Promise.<void>

Get an item in DB table

Kind: global function
Returns: Promise.<void> - operation result

Param Type Description
table string name

deleteItem(table) ⇒ Promise.<void>

Delete an item in DB table

Kind: global function
Returns: Promise.<void> - operation result

Param Type Description
table string name

setZoomlevels(zoomlevels)

Set options zoomlevels

Kind: global function

Param Type Description
zoomlevels array array of zoom values

setBounds(bounds)

Set Lat/Lng bounds of map to save

Kind: global function

Param Type Description
bounds LatLngBounds https://leafletjs.com/reference-0.7.7.html#latlngbounds

setStorageSize(function)

Sets status.storagesize equal to count of table rows

Kind: global function

Param Type Description
function callback to get the count

saveMap()

Prepare zoom levels to download and activate callback function to save(async) all map tiles on table name confirmation. Fires event 'savestart'.

Kind: global function

getTileUrls(zoom) ⇒ Array.<object>

getTileUrls for single zoomlevel

Kind: global function
Returns: Array.<object> - the tile urls, key, url

Param Type
L.latLngBounds object
zoom number

ControlStatus : Object

Status of ControlSaveTiles, keeps info about process during downloading and saving tiles. Used internal and as object for events.

Kind: global typedef
Properties

Name Type Description
storagesize number total number of saved tiles.
lengthToBeSaved number number of tiles that will be saved in db during current process
lengthSaved number number of tiles saved during current process
lengthLoaded number number of tiles loaded during current process
_tilesforSave array tiles waiting for processing
tnames array names of all DB tables