Slippy Tile
Slippy Tile helps parse a Tile scheme URL from a given Tile [x, y, zoom].
Install
$ npm install --save slippy-tile
Quickstart
import slippyTile from 'slippy-tile'
const tile = [10, 15, 8]
const url = slippyTile(tile, 'osm')
Providers
Name | Unique Key |
---|
OSM (Default) | osm |
OSM Cycle Map | osm-cycle |
OSM Humanitarian | osm-hot |
OSM Transport | osm-transport |
OSM Wikimedia | osm-wikimedia |
OSM Lyrk | osm-lyrk |
Bing Imagery | bing-imagery |
Strava Cycling & Running | strava |
National Geographic World Map | natgeo |
ESRI Imagery | esri-imagery |
ESRI Ocean Basemap | esri-ocean |
ESRI USA Topo Maps | esri-usa-topo |
ESRI World Street Map | esri-street |
ESRI World Topographic Map | esri-topo |
DigitalGlobe Imagery | digitalgloble-imagery |
DigitalGlobe Hybrid | digitalgloble-hybrid |
Scheme
You can provide your own scheme by following the same syntax as JOSM.
const scheme = 'https://{switch:a,b,c}.tile.openstreetmap.org/{zoom}/{x}/{y}.png'
const url = slippyTile([10, 15, 8], scheme)
Options
{x}
: Tile Column{y}
: Tile Row{-y}
: Tile Row using TMS tile scheme{zoom}
: Zoom Level{bbox}
: GeoJSON Bounding Box{quadkey}
: Microsoft's Quadkey{switch:1,2,3}
: Selects a random sample{height}
default = 256{width}
: default = 256{proj}
: default = EPSG:3857
slippyTile
Substitutes the given tile information [x,y,zoom] to the URL tile scheme.
Parameters
tile
Tile Tile [x, y, zoom]url
string URL Tile scheme or provider unique key
Examples
slippyTile([10, 15, 8], 'osm')
Returns string
parseSwitch
Replaces {switch:a,b,c} with a random sample.
Parameters
Examples
parseSwitch('http://tile-{switch:a,b,c}.openstreetmap.fr/hot/{zoom}/{x}/{y}.png')
Returns string Parsed URL with switch replaced
provider
Provider Lookup
Parameters
provider
string Provider unique key
Examples
provider('bing-imagery')
provider('osm')
Returns string url Tile URL scheme
sample
Sample an item from a given list
Parameters
collection
Array<any> List of items
Examples
sample(['a', 'b', 'c'])
Returns (string | number) Single item from the list
Changelog
1.2.4 - 2016-10-21
- Add
{s}
to switch cases as default ['a', 'b', 'c']
- Removed
js-yaml
dependency - Removed all
request
related dependencies - Removed
download
method - Added DigitalGlobe as provider
- Converted
source.json
to providers.yml
1.1.0 - 2016-10-14
- Changed default function to
url
- Added
download
feature - Fallbacks, request-promise dependency for downloading Tile data Buffer
- Update docs
1.0.0 - 2016-10-13
First Stable release of slippy-tile
.