add more of api
This commit is contained in:
parent
1a9c95e2c6
commit
2e7b12e212
|
@ -6,19 +6,46 @@ var lat = 40.2574448;
|
||||||
var lng = -111.7089464;
|
var lng = -111.7089464;
|
||||||
var level = 15;
|
var level = 15;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Convert from Lat / Lng
|
||||||
|
//
|
||||||
var key = S2.latLngToKey(lat, lng, level);
|
var key = S2.latLngToKey(lat, lng, level);
|
||||||
// '4/032212303102210'
|
|
||||||
console.log(key);
|
console.log(key);
|
||||||
|
// '4/032212303102210'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Convert between Hilbert Curve Quadtree Key and S2 Cell Id
|
||||||
|
//
|
||||||
var id = S2.keyToId(key);
|
var id = S2.keyToId(key);
|
||||||
// '9749618446378729472'
|
|
||||||
console.log(id);
|
console.log(id);
|
||||||
|
// '9749618446378729472'
|
||||||
|
|
||||||
|
var key = S2.idToKey(id);
|
||||||
|
console.log(key);
|
||||||
|
// '9749618446378729472'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Neighbors
|
||||||
|
//
|
||||||
var neighbors = S2.latLngToNeighborKeys(lat, lng, level);
|
var neighbors = S2.latLngToNeighborKeys(lat, lng, level);
|
||||||
// [ keyLeft, keyDown, keyRight, keyUp ]
|
|
||||||
console.log(neighbors);
|
console.log(neighbors);
|
||||||
|
// [ keyLeft, keyDown, keyRight, keyUp ]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Previous, Next, and Step
|
||||||
|
//
|
||||||
var nextKey = S2.nextKey(key);
|
var nextKey = S2.nextKey(key);
|
||||||
console.log(nextKey);
|
console.log(nextKey);
|
||||||
var prevKey = S2.prevKey(key);
|
var prevKey = S2.prevKey(key);
|
||||||
console.log(prevKey);
|
console.log(prevKey);
|
||||||
|
|
||||||
|
var backTenKeys = S2.stepKey(key, -10);
|
||||||
|
console.log(backTenKeys);
|
||||||
|
|
Loading…
Reference in New Issue