2016-07-26 04:42:53 +00:00
|
|
|
s2-geometry (JavaScript/ES5.1)
|
2014-01-23 17:05:56 +00:00
|
|
|
======================
|
|
|
|
|
2016-07-26 04:42:53 +00:00
|
|
|
A pure JavaScript/ES5.1 port of Google/Niantic's S2 Geometry library (used by Ingress, Pokemon GO)
|
2014-01-23 17:10:43 +00:00
|
|
|
|
|
|
|
Currently contains basic support for S2Cell
|
|
|
|
|
2016-07-26 04:42:53 +00:00
|
|
|
Simple Examples
|
|
|
|
---------------
|
2016-07-26 01:36:32 +00:00
|
|
|
|
|
|
|
```javascript
|
2016-07-26 04:42:53 +00:00
|
|
|
var level = 15;
|
|
|
|
var latlng = { lat: 40.2574448, lng: -111.7089464 };
|
|
|
|
var cell = S2.S2Cell.FromLatLng(latlng, level);
|
2016-07-26 01:36:32 +00:00
|
|
|
|
2016-07-26 04:42:53 +00:00
|
|
|
cell.getNeighbors(); // [ cellLeft, cellDown, cellRight, cellUp ]
|
2016-07-26 01:36:32 +00:00
|
|
|
|
2016-07-26 04:42:53 +00:00
|
|
|
cell.getLatLng(); // { lat: 40.2574448, lng: -111.7089464 }
|
2016-07-26 01:36:32 +00:00
|
|
|
```
|