GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - boromisp/leaflet-control-react: Leaflet Control that renders a react component onto the map

This repository was archived by the owner on Apr 25, 2020. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

11 Commits
11 Commits

Folders and files

NameName
Last commit message
Last commit date
src
src
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
package.json
package.json
 
 

Repository files navigation

leaflet-control-react

Leaflet Control that renders a react component onto the map.

Usage

The control is provided as a UMD module.

The essence of it is 10 simple lines of code, you should just copy, paste and customize it. Or you could grab it from npm:

npm i leaflet-control-react

Basic usage:

var label = 'Hello Leaflet!';

function getElement () {
  return React.DOM.div({ className: 'leaflet-control-with-react' }, label);
}

var reactControl = L.control.react({
  position: 'bottomleft',
  getElement: getElement
}).addTo(map);

/* Change some props, and re-render: */
label = 'Hello React!';
reactControl.render();

The getElement function gets the leaflet map as its argument.

The react components are rendered into a div with leaflet-control-react, and the default leaflet-control classes.

Options

getElement - A function with a single L.Map argument. The return value is rendered as:

ReactDOM.render(this.options.getElement(this._map), this._container);

when the control is added to the map, and anytime the .render() function is called.

position - Inherited from L.Control

Methods

render() - Re-renders the react component. Could be called to change top-level props for example.

Events

You should be able to use the react event system, since it's just a thin wrapper around your react component.

License

ISC

About

Leaflet Control that renders a react component onto the map

Resources

Readme
ISC license
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.