Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

slippy-tile

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slippy-tile

Helps convert Slippy Map url tile schemas

  • 1.13.1
  • npm
  • Socket score

Version published
Weekly downloads
10
decreased by-23.08%
Maintainers
1
Weekly downloads
 
Created
Source

Slippy Tile

Build Status Coverage Status npm version MIT licensed

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 browser (ES5)

<script src="https://unpkg.com/slippy-tile/docs/slippy-tile.min.js"></script>

Quickstart

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.parse(tile, scheme)
//= https://b.tile.openstreetmap.org/8/10/15.png

Providers

NameUnique Key
OpenStreetMap Standardopenstreetmap.standard
OpenStreetMap Cycle Mapopenstreetmap.cycle
OpenStreetMap Humanitarianopenstreetmap.hot
OpenStreetMap Transportopenstreetmap.transport
OpenStreetMap Wikimediaopenstreetmap.wikimedia
OpenStreetMap Lyrkopenstreetmap.lyrk
Bing Imagerybing.imagery
Strava Cycling & Runningstrava.both
National Geographic World Mapesri.natgeo
ESRI Imageryesri.imagery
ESRI Ocean Basemapesri.ocean
ESRI USA Topo Mapsesri.usatopo
ESRI World Street Mapesri.street
ESRI World Topographic Mapesri.topo
DigitalGlobe Imagerydigitalglobe.imagery
DigitalGlobe Hybriddigitalglobe.hybrid
Mapbox Imagerymapbox.imagery
Mapbox Outdoorsmapbox.outdoors

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.parse([10, 15, 8], scheme)
//= https://b.tile.openstreetmap.org/8/10/15.png

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
  • {quadkey} or {q}: Microsoft's Quadkey
  • {switch:1,2,3}: Selects a random sample
  • {height} default = 256
  • {width}: default = 256
  • {proj}: default = EPSG:3857

API

Table of Contents

parse

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

Examples

slippyTile.parse([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

wms

Parse WMS URL to friendly SlippyTile format

Parameters

  • tile Tile Tile [x, y, z]
  • url string WMTS URL scheme

Examples

slippyTile.wms([10, 15, 8], 'https://<Tile Server>/?layers=imagery&SRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox}')
//='https://<Tile Server>/?layers=imagery&SRS=EPSG:3857&WIDTH=256&HEIGHT=256&BBOX=-165.9375,82.676285,-164.53125,82.853382'

Returns string parsed URL

wmts

Parse WMTS URL to friendly SlippyTile URL format

Parameters

Examples

slippyTile.wmts('https://<Tile Server>/WMTS/tile/1.0.0/Imagery/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.jpg')
//='https://<Tile Server>/WMTS/tile/1.0.0/Imagery/default/GoogleMapsCompatible/{z}/{y}/{x}.jpg'

Returns string parsed URL

parseSwitch

Replaces {switch:a,b,c} with a random sample.

Parameters

Examples

slippyTile.parseSwitch('http://tile-{switch:a,b,c}.openstreetmap.fr/hot/{zoom}/{x}/{y}.png')
//='http://tile-b.openstreetmap.fr/hot/{zoom}/{x}/{y}.png'

Returns string Parsed URL with switch replaced

sample

Sample an item from a given list

Parameters

  • array Array List of items

Examples

slippyTile.sample(['a', 'b', 'c'])
//='b'

Returns any Single item from the list

Keywords

FAQs

Package last updated on 27 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc