chickencoding123 / leaflet-react-fibers

A high performance react reconciler for [leafletjs](https://www.leafletjs.com)

Home Page:https://chickencoding123.github.io/leaflet-react-fibers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

leaflet-react-fibers logo

leaflet-react-fibers

A high performance react library for leafletjs

npm license docs

How to use

npm i leaflet-react-fibers --save
# or
yarn add leaflet-react-fibers --save
import { LeafletMap, L } from "leaflet-react-fibers"

const JustAMap = () => {
  return (
    <LeafletMap options={{ crs: L.CRS.Simple }}>
      <lfRectangle bounds={[[50, 50], [150, 100]]} options={{ fillColor: 'black' }} add={() => { console.log('added a rectangle layer') }} />
    </LeafletMap>
  )
}

See Docs for various examples.

JSX renderer

You must provide a JSX renderer when embedding HTML in lfPopup or lfTooltip otherwise their contents are ignored, this is by design:

ℹ️ You do NOT have to use react-dom, any JSX renderer will suffice.

import { LeafletMap, L } from "leaflet-react-fibers"
import ReactDOM from "react-dom"

const PopupInsideARectangle = () => {
  return (
    <LeafletMap options={{ crs: L.CRS.Simple }} jsxRenderer={ReactDOM.render}>
       <lfRectangle bounds={[[50, 50], [150, 100]]} options={{ fillColor: 'black' }} add={() => { console.log('added a rectangle layer') }}>
        <lfPopup latlng={[100, 100]} add={() => { console.log('added an popup layer') }}>
          <div>Hello world!</div>
        </lfPopup>
      </lfRectangle>
    </LeafletMap>
  )
}

Similar work

None of the libraries mentioned below provide mutability control out of the box and state management features.

  1. react-leaflet-fiber another fiber implementation.
  2. react-leaflet react wrapper for leaflet which comes with hooks.

Known Issues

[x] Mutability control does not work at the moment. This is a feature of this library that allows a layer to be explicitly mutable or immutable using a mutable prop.

Development

Clone this repository and simply run npm run storybook to get started.

About

A high performance react reconciler for [leafletjs](https://www.leafletjs.com)

https://chickencoding123.github.io/leaflet-react-fibers

License:MIT License


Languages

Language:TypeScript 93.9%Language:JavaScript 4.9%Language:CSS 0.7%Language:HTML 0.4%Language:Shell 0.1%