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 * as slippyTile from 'slippy-tile'
const tile = [10, 15, 8]
const url = slippyTile.url(tile, 'osm')
Providers
Name | Unique Key |
---|
OSM (Default) | osm, osm-standard |
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, bing-imagery |
Strava Cycling & Running | strava |
National Geographic World Map | natgeo |
ESRI Imagery | esri, 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 |
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.url([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
url
Substitutes the given tile information [x,y,zoom] to the URL tile scheme.
Parameters
tile
Tile Tile [x, y, zoom]scheme
string Tile scheme URL or provider unique key
Examples
const url = slippyTile.url([10, 15, 8], 'osm')
Returns string
download
Downloads Tile
Parameters
tile
Tile Tile [x, y, zoom]scheme
string Tile scheme URL or pre-loaded source unique key
Examples
const url = slippyTile.url([10, 15, 8], 'osm')
Returns Promise<Buffer> tile buffer
parseSwitch
Replaces {switch:a,b,c} with a random sample.
Parameters
Examples
const scheme = 'http://tile-{switch:a,b,c}.openstreetmap.fr/hot/{zoom}/{x}/{y}.png'
const url = slippyTile.parseSwitch(scheme)
Returns string Parsed URL with switch replaced
sourceLookup
Source Lookup
Parameters
source
string Source unique key
Examples
const scheme = slippyTile.providerLookup('bing')
Returns string scheme Tile scheme URL
sample
Sample an item from a given list
Parameters
collection
Array<any> List of items
Examples
const item = sample(['a', 'b', 'c'])
Returns (string | number) Single item from the list