quadkey-tilemath
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

quadkey-tilemath

npm version MIT licensed

The quadkey-tilemath provides functions for converting between geographical coordinates and tile coordinates using the Quadkey system. This system represents a hierarchical tiling of the Earth's surface as a quadtree, with each tile being assigned a unique identifier known as a Quadkey.

The quadkey-tilemath implements the TileSystem static class described here as a reference: http://msdn.microsoft.com/en-us/library/bb259689.aspx

Given a (longitude, latitude) and level produce a quadkey to be used in Bing Maps. Can also supply methods to generate a Google Maps TileXYZ

Class diagram

It is a conceptual class diagram for explanation only and differs from the actual implementation. plantuml

Install

$ npm install quadkey-tilemath

or

$ yarn add quadkey-tilemath

Usage

Converts a longitude, latitude to a quadkey.

import { tileMath } from 'quadkey-tilemath'

// Shibuya
const quadkey = tileMath.pointToQuadkey([139.69116, 35.63051], 20)

// 133002112303213
console.log(quadkey)

Converts a quadkey to lng lat point.

import { tileMath } from 'quadkey-tilemath'

const point = tileMath.quadkeyToPoint('13300211230301333312')

// 139.7014617919922, 35.657854158137965
console.log(point)

Demo using map

Here is a demo that actually draws the quadkey on the map using this library.
https://9revolution9.com/tools/geo/geocode/

Package Sidebar

Install

npm i quadkey-tilemath

Weekly Downloads

64

Version

0.1.1

License

MIT

Unpacked Size

17.8 kB

Total Files

19

Last publish

Collaborators

  • glassonion1