All Projects → yuzhva → React Leaflet Markercluster

yuzhva / React Leaflet Markercluster

Licence: mit
React wrapper of the official Leaflet.markercluster for react-leaflet

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Leaflet Markercluster

Kepler
The open source full-stack geosocial network platform
Stars: ✭ 125 (-38.12%)
Mutual labels:  leaflet
Mapbox.js
Mapbox JavaScript API, a Leaflet Plugin
Stars: ✭ 1,819 (+800.5%)
Mutual labels:  leaflet
Geopackage Js
GeoPackage JavaScript Library
Stars: ✭ 191 (-5.45%)
Mutual labels:  leaflet
Leaflet.canvaslayer.field
Load and style Raster files in Leaflet (geotiff & asciigrid)
Stars: ✭ 128 (-36.63%)
Mutual labels:  leaflet
Dtp Stat
Карта ДТП
Stars: ✭ 141 (-30.2%)
Mutual labels:  leaflet
Tangram
WebGL map rendering engine for creative cartography
Stars: ✭ 1,964 (+872.28%)
Mutual labels:  leaflet
Leaflet Iiif
Leaflet plugin for viewing IIIF images
Stars: ✭ 116 (-42.57%)
Mutual labels:  leaflet
React Leaflet Demo
Demo of a Leaflet map created with React
Stars: ✭ 200 (-0.99%)
Mutual labels:  leaflet
Papyruscs
PapyrusCS renders maps of Minecraft: Bedrock Edition worlds using C#, LevelDB and leaflet.
Stars: ✭ 146 (-27.72%)
Mutual labels:  leaflet
Wind Layer
🎏 🚀 wind-layer | a openlayers && amap && bmap && leaflet && mapbox-gl extension to windjs
Stars: ✭ 188 (-6.93%)
Mutual labels:  leaflet
Vue2leaflet
Vue 2 components for Leaflet maps
Stars: ✭ 1,809 (+795.54%)
Mutual labels:  leaflet
Leaflet.storage
Manage map and features with Leaflet and expose them for backend storage through an API.
Stars: ✭ 138 (-31.68%)
Mutual labels:  leaflet
Leaflet Tilelayer Baidugaode
leaflet 加载百度瓦片地图图层 以及高德 、天地图等国内常用地图
Stars: ✭ 175 (-13.37%)
Mutual labels:  leaflet
Flutter map
A Flutter map widget inspired by Leaflet
Stars: ✭ 1,886 (+833.66%)
Mutual labels:  leaflet
Mapsapi
Карты 2ГИС — это точные данные обо всех объектах города, включая новостройки, с детализацией до заборов и внутриквартальных проездов.
Stars: ✭ 193 (-4.46%)
Mutual labels:  leaflet
React Leaflet Heatmap Layer
A custom layer for heatmaps in react-leaflet
Stars: ✭ 122 (-39.6%)
Mutual labels:  leaflet
Node Tileserver
A lightweight tileserver based on NodeJS for serving bitmap and vector tiles.
Stars: ✭ 148 (-26.73%)
Mutual labels:  leaflet
Ember Leaflet
🔥 🍃 Easy and declarative mapping for ember
Stars: ✭ 201 (-0.5%)
Mutual labels:  leaflet
Leaflet.extras
Extra functionality for leaflet R package.
Stars: ✭ 193 (-4.46%)
Mutual labels:  leaflet
Greinerhormann
Greiner-Hormann polygon clipping algorithm. Does AND, OR, XOR. Plays nicely with Leaflet. Handles non-convex polygons and multiple clipping areas. ~3kb footprint, no dependencies
Stars: ✭ 176 (-12.87%)
Mutual labels:  leaflet

React leaflet markercluster

npm Code Climate npm license

React wrapper of Leaflet.markercluster for react-leaflet

React leaflet markercluster

Examples with the Documentation: https://yuzhva.github.io/react-leaflet-markercluster/
CodeSandbox Getting Started

Description

If you are faced with an issue with markers overlapping during map zooming, or they are overlapping because they are close to each other - you probably need to group them.
That is what you can do with react-leaflet-markercluster.

Just grab your markers inside <MarkerClusterGroup /> component, right after <TileLayer />:

import MarkerClusterGroup from 'react-leaflet-markercluster';

<MarkerClusterGroup>
  <Marker position={[49.8397, 24.0297]} />
  <Marker position={[52.2297, 21.0122]} />
  <Marker position={[51.5074, -0.0901]} />
</MarkerClusterGroup>;

Note: Before getting started, please see these useful guides:

Table of Contents

Getting started

1. Install package:

yarn add [email protected] # yarn
npm install react-leaflet-markercluster # npm

NOTE: the @next is required for react-leaflet v3 support. If you are still using react-leaflet v3, add dependency as [email protected]^2.x.x

The react-leaflet-markercluster requires leaflet.markercluster as peerDependency

(Leaflet and react-leaflet also should be installed)

yarn add leaflet.markercluster leaflet react-leaflet # yarn
npm install leaflet.markercluster leaflet react-leaflet # npm

2. Import markercluster and leaflet styles:

@import '~leaflet/dist/leaflet.css'; // sass
@import '~react-leaflet-markercluster/dist/styles.min.css'; // sass

require('~leaflet/dist/leaflet.css'); // inside .js file
require('react-leaflet-markercluster/dist/styles.min.css'); // inside .js file

Or include CSS styles directly to the head of HTML file:

<link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" />

<link
  rel="stylesheet"
  href="https://unpkg.com/react-leaflet-markercluster/dist/styles.min.css"
/>

3. Write some simple react-leaflet Map:

import { MapContainer, TileLayer, Marker } from 'react-leaflet';

<MapContainer
  className="markercluster-map"
  center={[51.0, 19.0]}
  zoom={4}
  maxZoom={18}
>
  <TileLayer
    url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
    attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
  />

  <Marker position={[49.8397, 24.0297]} />
  <Marker position={[52.2297, 21.0122]} />
  <Marker position={[51.5074, -0.0901]} />
</MapContainer>;

NOTE: Remember to add map styles .markercluster-map { height: 90vh; }.

4. Just grab your markers inside <MarkerClusterGroup /> component, right after <TileLayer />:

import MarkerClusterGroup from 'react-leaflet-markercluster';

<MarkerClusterGroup>
  <Marker position={[49.8397, 24.0297]} />
  <Marker position={[52.2297, 21.0122]} />
  <Marker position={[51.5074, -0.0901]} />
</MarkerClusterGroup>;

More examples with the Documentation
CodeSandbox Getting Started

API

Just pass whatever option you need from All Leaflet.markercluster Options to MarkerClusterGroup as prop.

For example:

<MarkerClusterGroup showCoverageOnHover={false} />

or:

const createClusterCustomIcon = function (cluster) {
  return L.divIcon({
    html: `<span>${cluster.getChildCount()}</span>`,
    className: 'marker-cluster-custom',
    iconSize: L.point(40, 40, true),
  });
}

<MarkerClusterGroup iconCreateFunction={createClusterCustomIcon} />

P.S: Examples for v1 are available at CHANGELOG.md

Event listeners

You are able to add any listener, supported by Leaflet, with simple on property prefix.

How to run DEV env

1. Clone the repo:

git clone https://github.com/YUzhva/react-leaflet-markercluster.git

2. Install all dependencies:

yarn install --no-lockfile # yarn
npm install # npm

3. Start the server:

yarn dev # yarn
npm run dev # npm

4. After starting the server, storybook should automatically open the following address:

http://localhost:8080/

Contributors ✨

Thanks goes to these wonderful people: Avatars rendered by contributors-img.

Special thanks to:

Contributing

All sources are placed in the ./src folder:

1. Fork the repo.

2. Edit react-leaflet-markercluster.js plugin or style.scss style files.

3. Commit your changes and open Pull Request.

🍺 Thank you for contribution 🍺

UMD

UMD builds are available on unpkg:

<!-- unpkg, production code (minified) -->
<script src="https://unpkg.com/react-leaflet-markercluster/dist/index.js"></script>
<!-- unpkg, development code -->
<script src="https://unpkg.com/react-leaflet-markercluster/src/react-leaflet-markercluster.js"></script>

<!-- unpkg, production styles (minified) -->
<link
  rel="stylesheet"
  type="text/css"
  href="https://unpkg.com/react-leaflet-markercluster/dist/styles.min.css"
/>
<!-- unpkg, development styles -->
<link
  rel="stylesheet"
  type="text/css"
  href="https://unpkg.com/react-leaflet-markercluster/src/styles.scss"
/>

License

MIT License, see LICENSE file.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].