https://github.com/ghettovoice/ol-tilecache
OpenLayers tile url function to load tile seeded with TileCache URL scheme
https://github.com/ghettovoice/ol-tilecache
hacktoberfest ol ol-plugins ol-tilecache ol3 ol4 openlayers openlayers3 openlayers4 tilecache
Last synced: 2 months ago
JSON representation
OpenLayers tile url function to load tile seeded with TileCache URL scheme
- Host: GitHub
- URL: https://github.com/ghettovoice/ol-tilecache
- Owner: ghettovoice
- License: mit
- Created: 2015-10-30T15:02:36.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-10-22T11:35:18.000Z (over 4 years ago)
- Last Synced: 2025-03-11T22:16:47.336Z (3 months ago)
- Topics: hacktoberfest, ol, ol-plugins, ol-tilecache, ol3, ol4, openlayers, openlayers3, openlayers4, tilecache
- Language: JavaScript
- Homepage:
- Size: 604 KB
- Stars: 10
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.com/ghettovoice/ol-tilecache)
[](https://coveralls.io/github/ghettovoice/ol-tilecache?branch=master)
[](https://github.com/ghettovoice/ol-tilecache/releases)
[](https://www.npmjs.org/package/ol-tilecache)
[](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
// plugin exports global variable TileCacheUrlFn
// in addition it also exported to `ol.tileCacheUrlFn` field (for backward compatibility).```
## 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