react-leaflet-extendable

Extendable React components for Leaflet maps

Usage no npm install needed!

<script type="module">
  import reactLeafletExtendable from 'https://cdn.skypack.dev/react-leaflet-extendable';
</script>

README

React-Leaflet-Extendable

npm version

This is literally just a fork of react-leaflet that adds the ability to directly extend components. Unless you have an issue specifically about extending components DO NOT raise issues here. Raise them on the react-leaflet repository.

This repository exists because of https://github.com/PaulLeCam/react-leaflet/issues/506

Please read through that issue before deciding if you actually should use this library and not react-leaflet. For most use cases react-leaflet will be fine.

TLDR; react-leaflet v2 makes it impossible to directly extend these components:

  • AttributionControl
  • Circle
  • ExtendableCircle
  • FeatureGroup
  • GeoJSON
  • ImageOverlay
  • LayerGroup
  • LayersControl
  • Marker
  • Pane
  • Polygon
  • Polyline
  • Popup
  • Rectangle
  • ScaleControl
  • TileLayer
  • Tooltip
  • VideoOverlay
  • WMSTileLayer
  • ZoomControl

This fork lets you extend those.

The extendable exports of these components are all formatted like: Extendable<COMPONENT>

e.g. ExtendableAttributionControl, ExtendableCircle, etc...

Usage

import { ExtendableTileLayer, withLeaflet } from 'react-leaflet-extendable'

class MyCustomTileLayer extends ExtendableTileLayer {
    // Go nuts here
}
export default withLeaflet(MyCustomTileLayer)

License

MIT
See LICENSE file.