An open API service indexing awesome lists of open source software.

https://github.com/urbica/react-map-gl-cluster

Urbica React Cluster Component for Mapbox GL JS
https://github.com/urbica/react-map-gl-cluster

cluster clustering data-visualization map mapbox-gl mapbox-gl-js maps react supercluster webgl

Last synced: 5 months ago
JSON representation

Urbica React Cluster Component for Mapbox GL JS

Awesome Lists containing this project

README

          

# Urbica React Mapbox GL Cluster

[![Build Status](https://img.shields.io/circleci/project/github/urbica/react-map-gl-cluster.svg?style=popout)](https://circleci.com/gh/urbica/react-map-gl-cluster)
![npm](https://img.shields.io/npm/dt/@urbica/react-map-gl-cluster.svg)
![npm](https://img.shields.io/npm/v/@urbica/react-map-gl-cluster.svg)

Cluster component for [Urbica React Components Library for Mapbox GL JS](https://github.com/urbica/react-map-gl).

## Installation

```shell
npm install mapbox-gl supercluster @urbica/react-map-gl @urbica/react-map-gl-cluster
```

...or if you are using yarn:

```shell
yarn add mapbox-gl supercluster @urbica/react-map-gl @urbica/react-map-gl-cluster
```

## Usage

```jsx
import { randomPoint } from '@turf/random';
import MapGL, { Marker } from '@urbica/react-map-gl';
import Cluster from '@urbica/react-map-gl-cluster';
import 'mapbox-gl/dist/mapbox-gl.css';

const bbox = [-160, -70, 160, 70];
const points = randomPoint(50, { bbox }).features;
points.forEach((point, index) => (point.id = index));

initialState = {
viewport: {
latitude: 0,
longitude: 0,
zoom: 0
}
};

const style = {
width: '20px',
height: '20px',
color: '#fff',
background: '#1978c8',
borderRadius: '20px',
textAlign: 'center'
};

const ClusterMarker = ({ longitude, latitude, pointCount }) => (

{pointCount}


);

setState({ viewport })}
{...state.viewport}
>

{points.map(point => (



))}

;
```