{"id":13907412,"url":"https://github.com/MazeMap/Leaflet.TileLayer.PouchDBCached","last_synced_at":"2025-07-18T05:31:35.057Z","repository":{"id":27874090,"uuid":"31365141","full_name":"MazeMap/Leaflet.TileLayer.PouchDBCached","owner":"MazeMap","description":"A Leaflet tile layer which caches into PouchDB for offline use","archived":true,"fork":false,"pushed_at":"2024-11-21T14:53:26.000Z","size":74,"stargazers_count":208,"open_issues_count":30,"forks_count":67,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-06-22T20:04:56.795Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MazeMap.png","metadata":{"files":{"readme":"readme.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2015-02-26T12:05:04.000Z","updated_at":"2025-04-08T11:57:39.000Z","dependencies_parsed_at":"2023-09-27T03:38:19.288Z","dependency_job_id":null,"html_url":"https://github.com/MazeMap/Leaflet.TileLayer.PouchDBCached","commit_stats":{"total_commits":26,"total_committers":9,"mean_commits":2.888888888888889,"dds":0.5769230769230769,"last_synced_commit":"179c3ce921c04cb989e5cb42288539dbdafc4400"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/MazeMap/Leaflet.TileLayer.PouchDBCached","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MazeMap%2FLeaflet.TileLayer.PouchDBCached","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MazeMap%2FLeaflet.TileLayer.PouchDBCached/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MazeMap%2FLeaflet.TileLayer.PouchDBCached/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MazeMap%2FLeaflet.TileLayer.PouchDBCached/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MazeMap","download_url":"https://codeload.github.com/MazeMap/Leaflet.TileLayer.PouchDBCached/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MazeMap%2FLeaflet.TileLayer.PouchDBCached/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265705365,"owners_count":23814434,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-06T23:01:55.703Z","updated_at":"2025-07-18T05:31:34.785Z","avatar_url":"https://github.com/MazeMap.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Deprecated\n\nThis repository is no longer maintained and is deprecated. Please be aware that it may not work with the latest versions of its dependencies.\n\n---\n\nAllows all Leaflet TileLayers to cache into PouchDB for offline use, in a transparent fashion.\n\nThere is a [demo](http://mazemap.github.io/Leaflet.TileLayer.PouchDBCached/demo.html) available, which shows cache hits/misses/seeds in the browser's developer console.\n\n# Dependencies\n\nTested with Leaflet 1.4.0 and PouchDB 7.0.0.\n\nYou probably want to load Leaflet, PouchDB and Leaflet.TileLayer.PouchDB like so:\n\n```html\n\t\u003cscript src=\"https://unpkg.com/leaflet@^1.0.0/dist/leaflet-src.js\"\u003e\u003c/script\u003e\n\t\u003cscript src=\"https://unpkg.com/pouchdb@^5.2.0/dist/pouchdb.js\"\u003e\u003c/script\u003e\n\t\u003cscript src=\"https://unpkg.com/leaflet.tilelayer.pouchdbcached@latest/L.TileLayer.PouchDBCached.js\"\u003e\u003c/script\u003e\n```\n\nIf you are still using Leaflet 0.7.x, the latest compatible release is [v0.1.0](https://github.com/MazeMap/Leaflet.TileLayer.PouchDBCached/releases/tag/v0.1.0).\n\n\n# Usage\n\nThe plugin modifies the core `L.TileLayer` class, so it should be possible to cache any tile layer.\n\nTo use, add the option `useCache` with a value of `true` when instantiating your layer. You probably want to use Leaflet's `crossOrigin` option, like so:\n\n```javascript\nvar layer = L.tileLayer('https://whatever/{z}/{x}/{y}.png', {\n\tmaxZoom: 18,\n\n\tuseCache: true,\n\tcrossOrigin: true\n});\n```\n\nOptions available are as follows:\n\n* `useCache`: set to true in order to enable the cache. This option must be set at initialization time.\n* `saveToCache`: Whether to save new tiles to the cache or not. Defaults to true.\n* `useOnlyCache`: Whether to fetch tiles from the network or not. Defaults to false.\n* `cacheMaxAge`: Time, in milliseconds, for any given tile to be considered 'fresh'. Tiles older than this value will be re-requested from the network. Defaults to 24 hours.\n* `cacheURLMask`: A regular expresstion to mask the URL so that access tokens and the sort won't cause cache misses. (e.g. /access_token=[^\u0026]*/)\n\nNew functions available are as follows:\n* `seed`: Starts seeding the cache for a given bounding box (a `L.LatLngBounds`), and between the two given zoom levels.\n\nNew events available are as follows:\n\n* `tilecachehit`: Fired when a tile has been found in the tile cache. The event includes data as per http://leafletjs.com/reference.html#tile-event\n* `tilecachemiss`: Like `tilecachehit`, but is fired when the tile has *not* been found in the cache.\n* `tilecacheerror`: Fired when there was an error trying to save a tile in the cache. The event data includes:\n * `tile`: A reference to the failed tile\n * `error`: The error message, probably related to CORS.\n* `seedstart`: Fired when a layer cache has started seeding. The event data includes:\n * `bbox`: bounding box for the seed operation, as per the `L.TileLayer.seed()` function call.\n * `minZoom` and `maxZoom`: zoom levels the seed operation, as per the `L.TileLayer.seed()` function call.\n * `queueLength`: (integer) Total number of tiles to be loaded during the seed operation.\n* `seedend`: Fired when a layer cache has finished seeding.\n* `seedprogress`: Fired every time a tile is cached during a seed operation\n * `remainingLength`: (integer) How many tiles are left in the seed queue. Starts with a value of `queueLength` and drops down to zero.\n\n\n# Cross-Origin Resource Sharing\n\nDue to the tile images being parsed and stored by the browser (technically, extracting data from a canvas in which a external image has been loaded into), the tiles must come from a tile server which allows CORS (Cross-Origin Resource Sharing) on the tiles. So tiles must have a CORS header allowing them to be loaded in the document where you're using this caching layer.\n\nIn other words: if chrome shows a grey map, and displays CORS-related messages in the console, make sure that your tileserver adds this header to all tiles:\n\n`Access-Control-Allow-Origin: *`\n\n\n# Underlying cache structure\n\nThis plugin uses an instance of PouchDB, named `offline-tiles`. PouchDB is a key-value store, so the key is the URL of a tile, and the value is a plain object containing a timestamp and the base64-encoded image.\n\n\n# License and stuff\n\nUnder MIT license.\n\nHeavily inspired by https://github.com/tbicr/OfflineMap\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMazeMap%2FLeaflet.TileLayer.PouchDBCached","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMazeMap%2FLeaflet.TileLayer.PouchDBCached","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMazeMap%2FLeaflet.TileLayer.PouchDBCached/lists"}