Skip to content

failbetter-games/react-leaflet-pouchdb-tilelayer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-leaflet-pouchdb-tilelayer

version react-leaflet compatibility Build Status dependencies peer dependencies

React version of Leaflet.TileLayer.PouchDBCached

Installation

Install via NPM

npm install react-leaflet-pouchdb-tilelayer --save

Demo

https://codesandbox.io/s/competent-glade-xpy0b

Usage with React-Leaflet v2

This plugin is compatible with version 2 of React-Leaflet

import { Map, TileLayer, LayersControl } from "react-leaflet";
import PouchDBTileLayer from "react-leaflet-pouchdb-tilelayer";

<Map center={[22.287, 114.1694]} zoom={15}>
  <LayersControl position="topleft">
    <LayersControl.BaseLayer checked name="PouchDBTileLayer">
      <PouchDBTileLayer
        useCache={true}
        crossOrigin={true}
        attribution='&copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors'
        url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
      />
    </LayersControl.BaseLayer>
    <LayersControl.BaseLayer name="TileLayer">
      <TileLayer
        url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
        attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
      />
    </LayersControl.BaseLayer>
  </LayersControl>
</Map>;

Control options

position

{ useCache: true }

Enable the cache logic

saveToCache

{ saveToCache: true }

Save the map tile to PouchDB

useOnlyCache

{ useOnlyCache: false }

Load from PouchDB cache and do not download from web

cacheFormat

{ cacheFormat: 'image/png' }

The mine type

cacheMaxAge

{ cacheMaxAge: 3600000 }

cache age in millisecond unit

cacheNextZoomLevel

{ cacheNextZoomLevel: true }

pre-load and cache the next level tile

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%