Reputation: 808
I would like to render two distinct react components:
A leaflet map
A sidebar component where I render a list of checkbox to enable/disable GeoJSON layers.
I am using react-leaflet package. And I am using reflux store for keeping the list of all possible layers I will render in the map.
I would like to know whats the best approach for add layers on demand, using the checkbox onChange event. Thanks
Upvotes: 2
Views: 6936
Reputation: 11
import { Map, TileLayer, LayersControl } from 'react-leaflet'; const { Overlay } = LayersControl; use the overlay in your map, here is a detail example about this. https://github.com/PaulLeCam/react-leaflet/blob/master/example/components/layers-control.js
Upvotes: 0
Reputation: 673
In your checkbox events you would update a "layer toggle" value in your store. Assuming you are set up correctly this value should push a update to your page. So, all you have to do is conditionally render your page based on those "layer toggle" values saved in your store.
Let me know if you would like more explanation.
Upvotes: 2