@isias/isi.offlinemap
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

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);
    }
  })
  

Readme

Keywords

Package Sidebar

Install

npm i @isias/isi.offlinemap

Weekly Downloads

0

Version

0.0.6

License

ISC

Unpacked Size

12.5 kB

Total Files

7

Last publish

Collaborators

  • nhjelme