@isias/isi.offlinemap
v0.0.6
Published
Leaflet offline wms layer
Downloads
11
Readme
Offline layer for leaflet in Electron
based on https://github.com/allartk/leaflet.offline
Saves map tiles to indexdb
use the offlinelayer in Leaflet
import {tileLayers} from 'isi.offlinemap';
this.myMap = L.map('mapid')
tileLayers.offline('https://opencache.statkart.no/gatekeeper/gk/gk.open?', {
layers: 'topo4',
format: 'image/png',
transparent: false,
version: "1.0.0",
attribution: "Kartverket",
type: 'wms',
tms: true,
maxZoom: 20,
maxNativeZoom: 20
}).addTo(this.myMap);
Save tiles to indexdb (must run in render process)
const offlineMap = require('isi.offlinemap').saveTiles
const gpsTrack = [{lat:62.312,lon:7.623},...];
// asyc
(async () => {
try {
await offlineMap.downloadTrackTiles(gpsTrack,(total,current) => {
// progress callback, shows download progress of tiles
});
} catch (e) {
console.log('error',e);
}
})