Launch Week Day 2: Introducing Reports: An Extensible Reporting Framework for Socket Data.Learn More
Socket
Book a DemoSign in
Socket

react-leaflet-deflate

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-leaflet-deflate

React wrapper of Leaflet.Deflate. Substitues polygons and lines with markers when screen size falls below a defined threshold.

latest
Source
npmnpm
Version
3.1.2
Version published
Maintainers
1
Created
Source

react-leaflet-deflate

version react-leaflet compatibility issues downloads MIT License

React wrapper of Leaflet.Deflate for react-leaflet.

Substitutes polygons and lines with markers when their screen size falls below a defined threshold.

Tested with React 19.2.0, Leaflet 1.9.4, React-Leaflet 5.0.0, React-Leaflet 4.0.0, Leaflet.Deflate 2.1.0

Example

Demos

VersionDemo
react-leaflet@1.9.1CodePen
react-leaflet@2.xCodePen
react-leaflet@5.xCodePen

Installation

Install via NPM

npm install --save react-leaflet-deflate

react-leaflet-deflate requires leaflet.markercluster as peerDependency

(React, Leaflet, react-leaflet also should be installed)

npm install --save leaflet.markercluster

Usage example

react-leaflet v5

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

const geojson = {...};

<MapContainer center={[2.935403, 101.448205]} zoom={10}>
  <TileLayer
    url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
    attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
  />

  <Deflate
    data={geojson}
    minSize={10}
    markerCluster={true}
  />
</MapContainer>

Options

OptionTypeDefaultDescription
dataobject{}Required. A valid GeoJSON object.
minSizeint20Defines the minimum width and height in pixels for a path to be displayed in its actual shape.
markerOptionsobject or function{}Optional. Customize the markers of deflated features using Leaflet marker options.
markerClusterbooleanfalseIndicates whether markers should be clustered. Requires Leaflet.markercluster.
markerClusterOptionsobject{}Optional. Customize the appearance and behaviour of clustered markers using Leaflet.markercluster options.
pointToLayerfunction{}Leaflet geojson pointToLayer options.
stylefunction{}Style to apply to polygons or lines. Leaflet geojson style options.
onEachFeaturefunction{}Function to execute on each geojson feature. Leaflet geojson onEachFeature options.
filterfunction{}Filter function to apply to geojson features. Leaflet geojson filter options.

Credits

  • oliverroick and the other contributors to for the original work on Leaflet.Deflate.
  • clintharris for updating react-leaflet-deflate to reference Leaflet.Deflate as an external dependency, support property changes, and work with react-leaflet v2.

License

MIT License

Keywords

react

FAQs

Package last updated on 11 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts