Skip to content
This repository was archived by the owner on Apr 25, 2020. It is now read-only.

Commit 78e230e

Browse files
committed
Create README.md
1 parent cca7094 commit 78e230e

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# leaflet-control-react
2+
3+
Leaflet Control that renders a react component onto the map.
4+
5+
## Usage
6+
7+
The control is provided as a [UMD](https://github.com/umdjs/umd) module.
8+
9+
Basic usage:
10+
11+
```js
12+
var label = 'Hello Leaflet!';
13+
14+
function getElement () {
15+
return React.DOM.div({ className: 'leaflet-control-with-react' }, label);
16+
}
17+
18+
var reactControl = L.control.react({
19+
position: 'bottomleft',
20+
getElement: getElement
21+
}).addTo(map);
22+
23+
/* Change some props, and re-render: */
24+
label = 'Hello React!';
25+
reactControl.render();
26+
```
27+
28+
The `getElement` function gets the leaflet `map` as its argument.
29+
30+
The react components are rendered into a `div` with `leaflet-control-react`, and the default `leaflet-control` classes.
31+
32+
## Options
33+
34+
`getElement` - A function with a single `L.Map` argument. The return value is rendered as:
35+
```
36+
ReactDOM.render(this.options.getElement(this._map), this._container);
37+
```
38+
when the control is added to the map, and anytime the `.render()` function is called.
39+
40+
`position` - Inherited from `L.Control`
41+
42+
## Events
43+
44+
You should be able to use the [react event system](https://facebook.github.io/react/docs/events.html), since it's just a thin wrapper around your react component.
45+
46+
## License
47+
48+
ISC

0 commit comments

Comments
 (0)