A react-leaflet plugin for leaflet-sidebar-v2
npm install react-leaflet-sidebarv2Sidebar as a _sibling_ component of
Map, contained in a wrapper div so the sidebar is
Tab children are
Sidebar component is stateless; all state information should be
onOpen and onClose callback. A minimal example might look
Map needs a sidebar-map class, and the Sidebar needs to be
Map):
jsx
import React, { Component } from 'react';
import { Map, TileLayer } from 'react-leaflet';
import { Sidebar, Tab } from 'react-leaflet-sidebarv2';
export default class SidebarExample extends Component {
constructor(props) {
super(props);
this.state = {
collapsed: false,
selected: 'home',
};
}
onClose() {
this.setState({collapsed: true});
}
onOpen(id) {
this.setState({
collapsed: false,
selected: id,
})
}
render() {
return (
onOpen={this.onOpen.bind(this)} onClose={this.onClose.bind(this)}>
No place like home!
Settings dialogue.
);
}
}
``