@whins/geo-cluster
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

geo-cluster

This is modification of geocluster on Typescript

Install

npm install @whins/geo-cluster

API

let clusters: ICluster = new Geocluster(coordinates[, zoom]).clusters;

coordinates is an Array of ICoordinate { latitude: number; longitude: number; }.

zoom value from 1 to 20.

clusters is an Array of cluster objects ICluster, which have centroid and elements properties.

Sample Code

import { ICoordinate, ICluster, Geocluster } from "geo-cluster";

let zoom = 2;

let coordinates: ICoordinate = [
    {
        latitude: 10,
        longitude: 20
    },
    {
        latitude: 20,
        longitude: 20
    },
    {
        latitude: 10,
        longitude: 30
    },
    {
        latitude: 40,
        longitude: 20
    }
];

let clusters: ICluster = new Geocluster(coordinates, zoom).clusters;

Result

[
  {
    "centroid": {
      "latitude": 10.5,
      "longitude": 20.5
    },
    "elements": [
      {
        "latitude": 10,
        "longitude": 20
      },
      {
        "latitude": 11,
        "longitude": 21
      }
    ]
  },
  {
    "centroid": {
      "latitude": 40,
      "longitude": 34
    },
    "elements": [
      {
        "latitude": 40,
        "longitude": 35
      },
      {
        "latitude": 40,
        "longitude": 33
      }
    ]
  }
]

Dependencies (0)

    Dev Dependencies (12)

    Package Sidebar

    Install

    npm i @whins/geo-cluster

    Weekly Downloads

    247

    Version

    1.0.6

    License

    ISC

    Unpacked Size

    13.6 kB

    Total Files

    11

    Last publish

    Collaborators

    • whinsler