# ol-tilecache

> OpenLayers tile url function to load tile seeded with TileCache url scheme

Latest version **7.0.0** (published 2020-06-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install ol-tilecache
pnpm add ol-tilecache
yarn add ol-tilecache
bun add ol-tilecache
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 7.0.0 |
| Published | 2020-06-28 |
| First published | 2017-03-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >= 10.0 |
| Dependencies | 1 |
| Unpacked size | 60.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Vladimir Vershinin |
| Maintainers | ghettovoice |
| Keywords | ol, openlayers, tilecache, ol-tilecache, tile url function, map, mapping, ol plugins, openlayers plugins |

## Links

- npm: https://www.npmjs.com/package/ol-tilecache
- Repository: https://github.com/ghettovoice/ol-tilecache
- Issues: https://github.com/ghettovoice/ol-tilecache/issues
- npm.io page: https://npm.io/package/ol-tilecache

## Dependencies (1)

- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.10.3

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 7.0.0 (latest) — 2020-06-28
- 6.0.0 — 2020-04-28
- 5.0.0 — 2019-10-24
- 4.0.0 — 2019-10-01
- 3.0.2 — 2019-01-09
- 3.0.1 — 2018-07-12
- 3.0.0 — 2018-07-07
- 2.1.1 — 2018-02-09
- 2.1.0 — 2018-02-08
- 2.0.0 — 2017-04-17
- 2.0.0-beta.4 — 2017-04-03
- 2.0.0-beta.3 — 2017-03-28
- 2.0.0-beta.2 — 2017-03-28
- 2.0.0-beta.1 — 2017-03-25
- 2.0.0-beta — 2017-03-23
- … 2 more at https://npm.io/package/ol-tilecache/versions

## README

[![Build Status](https://travis-ci.org/ghettovoice/ol-tilecache.svg?branch=master)](https://travis-ci.org/ghettovoice/ol-tilecache)
[![Coverage Status](https://coveralls.io/repos/github/ghettovoice/ol-tilecache/badge.svg?branch=master)](https://coveralls.io/github/ghettovoice/ol-tilecache?branch=master)
[![GitHub tag](https://img.shields.io/github/tag/ghettovoice/ol-tilecache.svg)](https://github.com/ghettovoice/ol-tilecache/releases)
[![view on npm](http://img.shields.io/npm/v/ol-tilecache.svg)](https://www.npmjs.org/package/ol-tilecache)
[![License](https://img.shields.io/github/license/ghettovoice/ol-tilecache.svg)](https://github.com/ghettovoice/ol-tilecache/blob/master/LICENSE)

# TileCache url function for OpenLayers

Allows create custom [`ol.TileUrlFunctionType`](http://openlayers.org/en/latest/apidoc/ol.html#.TileUrlFunctionType) to load tiles 
seeded with [TileCache](http://tilecache.org/).

## Installation

Install it with NPM (**recommended**):

```shell
# ES6 version for bundling with Webpack, Rollup and etc.
npm install ol ol-tilecache
```

```js
// Use as ES2015 module (based on NPM package `ol`)
import Map from 'ol/Map'
...
import * as TileCacheUrlFn from 'ol-tilecache'
// or only what you need
import { createTileUrlFunction } from 'ol-tilecache'
```

Or add from CDN:

```html
<script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.0.0/build/ol.js"></script>
<script src="https://unpkg.com/ol-tilecache@latest/dist/ol-tilecache.umd.js"></script>
<script>
  // plugin exports global variable TileCacheUrlFn
  // in addition it also exported to `ol.tileCacheUrlFn` field (for backward compatibility).
</script>
```

## Usage

Usage same as standard OpenLayers tile url functions.

### Members

#### createTileUrlFunction
**Arguments**

* `url : string` _URL template_
* `tileGrid : ol.tilegrid.TileGrid` _Custom tile grid. Default is EPSG:3857 x/y/z grid_
    
**Returns**: `ol.TileUrlFunctionType`

Available URL placeholders:
```
z | 0z - zoom level (simple number or padded with zero)
x1, x2, x3 - X axis index parts (remnant from dividing the tile X index on 10^9 broken down by 3 digits)
y1, y2, y3 - Y axis index parts (remnant from dividing the tile Y index on 10^9 broken down by 3 digits)
-y1, -y2, -y3 - inverted Y axis index parts (remnant from dividing the tile Y index on 10^9 broken down by 3 digits)
```
    
### Example usage:

```js
import Map from 'ol/Map'
import View from 'ol/View'
import TileLayer from 'ol/layer/Tile'
import XyzSource from 'ol/source/XYZ'
import { createTileUrlFunction } from 'ol-tilecache'

const map = new Map({
  target: 'map',
  view: new View({
    projection: 'EPSG:3857',
    center: [ 4189972.14, 7507950.67 ],
    zoom: 5
  }),
  layers: [
    new TileLayer({
      source: new XyzSource({
        tileUrlFunction: createTileUrlFunction('http://{a-z}.tiles.org/{0z}/{x1}/{x2}/{x3}/{-y1}/{-y2}/{-y3}.png')
      })
    })
  ]
})

```

### Build

```bash
git clone https://github.com/ghettovoice/ol-tilecache.git
npm install
# build
npm run build
# run test app
npm start
# run unit tests
npm test
```

## License

MIT (c) 2016-2020, Vladimir Vershinin

---
_Source: https://npm.io/package/ol-tilecache · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
