Skip to content

Slippy Tile helps parse a Tile scheme URL from a given Tile [x, y, zoom].

License

Notifications You must be signed in to change notification settings

DenisCarriere/slippy-tile

Repository files navigation

Slippy Tile

Build Status npm version Coverage Status MIT licensed ES5

Standard - JavaScript Style Guide

Slippy Tile helps parse a Tile scheme URL from a given Tile [x, y, zoom].

Install

npm

$ npm install --save slippy-tile

web

<script src="https://wzrd.in/standalone/slippy-tile@latest"></script>

Quickstart

var slippyTile = require('slippy-tile')
var tile = [10, 15, 8] // [x, y, zoom]
var scheme = 'https://{switch:a,b,c}.tile.openstreetmap.org/{zoom}/{x}/{y}.png'
var url = slippyTile(tile, scheme)
//= https://b.tile.openstreetmap.org/8/10/15.png

Scheme

You can provide your own scheme by following the same syntax as JOSM.

Options

  • {x} or {TileColumn}: Tile Column
  • {y} or {TileRow}: Tile Row for Google Maps Compatible scheme
  • {-y}: Tile Row for TMS scheme
  • {zoom} or {z} or {TileMatrix}: Zoom Level
  • {bbox}: GeoJSON Bounding Box
  • {bbox4326}: GeoJSON Bounding Box using EPSG:4326 (WGS84)
  • {bbox3857}: GeoJSON Bounding Box using EPSG:3857 (World Mercator)
  • {quadkey} or {q}: Microsoft's Quadkey
  • {switch:1,2,3}: Selects a random sample
  • {height} default = 256
  • {width}: default = 256
  • {size}: default = 256,256
  • {proj}: default = EPSG:3857
  • {format}: default = image/png

API

slippyTile

Substitutes the given tile information [x, y, z] to the URL tile scheme.

Parameters

  • tile Tile Tile [x, y, z]
  • url string URL Tile scheme or provider unique key
  • options Object Additional params Examples
slippyTile([10, 15, 8], 'https://{s}.tile.openstreetmap.org/{zoom}/{x}/{y}.png')
//='https://c.tile.openstreetmap.org/8/10/15.png'

Returns string parsed URL

About

Slippy Tile helps parse a Tile scheme URL from a given Tile [x, y, zoom].

Resources

License

Stars

Watchers

Forks

Packages

No packages published