Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

hexgrid-geo

gojuno20BSD-3-Clause1.0.1

HexGrid Geo

grid, hexagon, hex, hexgrid, geo

readme

HexGrid GEO

Basics

GEO wrapper for HexGrid.

ES5

var hg = require('hexgrid-geo'),
    HexGridGeo = hg.HexGridGeo
    PointGeo = hg.PointGeo,
    ProjectionSM = hg.ProjectionSM,
    Orientation = hg.Orientation;

var grid = new HexGridGeo(Orientation.FLAT, 500, ProjectionSM),
    hex = grid.hexAt(new PointGeo(-73.5, 40.3)),
    code = grid.hexToCode(hex),
    restoredHex = grid.hexFromCode(code),
    neighbors = grid.hexNeighbors(hex, 2),
    region = grid.createRegion([new PointGeo(-73.0, 40.0), new PointGeo(-74.0, 40.0), new PointGeo(-74.0, 41.0), new PointGeo(-73.0, 41.0)]),
    hexesInRegion = region.getHexes();

ES2016

import { HexGridGeo, PointGeo, ProjectionSM, Orientation } from 'hexgrid-geo'

let grid = new HexGridGeo(Orientation.FLAT, 500, ProjectionSM),
    hex = grid.hexAt(new PointGeo(-73.5, 40.3)),
    code = grid.hexToCode(hex),
    restoredHex = grid.hexFromCode(code),
    neighbors = grid.hexNeighbors(hex, 2),
    region = grid.createRegion([new PointGeo(-73.0, 40.0), new PointGeo(-74.0, 40.0), new PointGeo(-74.0, 41.0), new PointGeo(-73.0, 41.0)]),
    hexesInRegion = region.getHexes();