diff --git a/README.md b/README.md index 44f8b720..9370fd35 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,15 @@ # mutable-supercluster [](https://github.com/SegmentationFaults0/mutable_supercluster/actions/workflows/test.yml)  -_This repository is a fork from [mapbox/supercluster](https://github.com/mapbox/supercluster)._ +_This repository is a fork from [mapbox/supercluster](https://github.com/mapbox/supercluster), further inspired by [rorystephenson/supercluster_dart](https://github.com/rorystephenson/supercluster_dart.git)._ A Node.js library for fast and mutable geospatial point clustering. ```js -const index = new Supercluster({ radius: 40, maxZoom: 16 }); +const index = new Supercluster({ + radius: 40, + maxZoom: 16, + getId: (point) => point.id, +}); index.load(points); const clusters = index.getClusters([-180, -85, 180, 85], 2); @@ -58,6 +62,14 @@ Returns the zoom on which the cluster expands into several children (useful for Updates the point in the cluster with the same `id` (according to `getId`), with the given `properties`. If the given `id` is not present in the cluster, this method will throw an error. The location of the point (`point.geometry.coordinates`) can not be updated through this method. +#### `addPoint(point)` + +Adds the given `point` to the cluster. Just like `load()`, the given point must be a [GeoJSON Feature](https://tools.ietf.org/html/rfc7946#section-3.2) with its `geometry` a [GeoJSON Point](https://tools.ietf.org/html/rfc7946#section-3.1.2). + +#### `removePoint(id)` + +Removes the point with the same `id` (according to `getId`) from the cluster. + ## Options | Option | Default | Description | diff --git a/demo/index.html b/demo/index.html index f8f3908a..f77cf940 100644 --- a/demo/index.html +++ b/demo/index.html @@ -22,13 +22,15 @@ html, body, #map { - height: 100%; + height: 95%; margin: 0; }
+ +