# leaflet-superclaster

> Leaflet binding for supercluster

Latest version **0.1.5** (published 2020-01-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install leaflet-superclaster
pnpm add leaflet-superclaster
yarn add leaflet-superclaster
bun add leaflet-superclaster
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2020-01-15 |
| First published | 2019-07-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 528.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Rinat Gabdrashitov |
| Maintainers | grinat |

## Links

- npm: https://www.npmjs.com/package/leaflet-superclaster
- Repository: https://github.com/grinat/leaflet-superclaster
- Homepage: https://github.com/grinat/leaflet-superclaster#readme
- Issues: https://github.com/grinat/leaflet-superclaster/issues
- npm.io page: https://npm.io/package/leaflet-superclaster

## Dependencies (3)

- [core-js](https://npm.io/package/core-js.md) ^3.6.1
- [supercluster](https://npm.io/package/supercluster.md) ^6.0.2
- [worker-loader](https://npm.io/package/worker-loader.md) ^2.0.0

## Recent versions

- 0.1.5 (latest) — 2020-01-15
- 0.1.4 — 2019-12-30
- 0.1.3 — 2019-12-30
- 0.1.2 — 2019-12-30
- 0.1.1 — 2019-08-22
- 0.1.0 — 2019-08-08
- 0.0.9 — 2019-08-08
- 0.0.8 — 2019-07-11
- 0.0.7 — 2019-07-10
- 0.0.6 — 2019-07-10
- 0.0.5 — 2019-07-08
- 0.0.4 — 2019-07-08
- 0.0.3 — 2019-07-05
- 0.0.2 — 2019-07-05
- 0.0.1 — 2019-07-05

## README

# leaflet-superclaster

[![CircleCI](https://circleci.com/gh/grinat/leaflet-superclaster/tree/master.svg?style=svg)](https://circleci.com/gh/grinat/leaflet-superclaster/tree/master)

Leaflet binding for [supercluster](https://github.com/mapbox/supercluster)

| move         | static        |
| -------------   |:-------------:|
| ![](examples/move.gif) | ![](examples/static.gif)|
| [example](https://grinat.github.io/leaflet-superclaster/examples/static.html) | [example](https://grinat.github.io/leaflet-superclaster/examples/move.html)  |


```js
import * as L from 'leaflet'

import {SuperclusterGroup} from 'leaflet-superclaster'
import 'leaflet-superclaster/dist/supercluster.css'

this.superclusterGroup = new SuperclusterGroup().addTo(this.map)
this.superclusterGroup.on('point.click', function({parentLayer, layer, target}) {
  let popup = layer.getPopup()
  if (!popup) {
    popup = L.popup({
      autoClose: false,
      closeOnClick: false,
      autoPan: false
    }).setContent(JSON.stringify(layer.feature.properties))
    layer.bindPopup(popup).openPopup()
  }
})

this.superclusterGroup.on('layer.updated', function ({layer}) {
  const popup = layer.getPopup()
  if (popup && popup.isOpen()) {
    popup.setContent(JSON.stringify(layer.feature.properties))
  }
})

const features = [{
  properties: {
    // !! id in properties are required
    // used for redraw markers which changes the position
    id: 1
  },
  type: "Feature",
  geometry: {type: "Point", coordinates: [45, 66]}
}]
this.superclusterGroup.loadGeoJsonData(features)
```

## Methods

```
loadGeoJsonData(features) - set markers positions
keepPoint(id) - Save point id for keep in view useful if appended popup with keepView optio
unKeepPoint(id)
```

## Events


| name            | params                     | desciption |
| -------------   |:-------------:             | -----:|
| point.click     | parentLayer, layer, target | Fired on click by point |
| cluster.click     | parentLayer, layer, target | Fired on click by cluster |
| layer.created   | layer, feature              | fired on marker(point or cluster) create |
| layer.updated   | layer, target              | fired on layer position(lat, lng) was updated |
| draw            | layer, target                      | fired after markers draw, return layers with markers |
| end            |                       | all data in worker executed |
| wait            |                      | data execution in worker |

## Development
Run webpack in dev mode and server with fixtures data
```
npm run watch
```

## Tests
```
npm run test:e2e
```

### Fallback
For use in ie 11 with webpack. Install copy-webpack-plugin and copy leaflet-superclaster.worker.js to root folder:
```
const CopyPlugin = require('copy-webpack-plugin')

...
plugins: [
  new CopyPlugin([
    { from: 'node_modules/leaflet-superclaster/dist/leaflet-superclaster.worker.js', to: 'leaflet-superclaster.worker.js' }
  ])
]
...

```

---
_Source: https://npm.io/package/leaflet-superclaster · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
