react-leaflet-marker-layer
react-leaflet-marker-layer provides a simple
Usage
API
The MarkerLayer
component takes the following props:
markers
: an array of objects to be plottedlongitudeExtractor
: a function that returns the marker object's longitude e.g.marker => marker.lng
latitudeExtractor
: a function that returns the marker object's latitude e.g.marker => marker.lat
markerComponent
: (required) the React component to be rendered for each marker, this component will receive the following propsmarker
: the object from themarkers
arraystyle
: a style object for positioning, you should include these styles on your componentmap
: the Leaflet map object from thereact-leaflet
MapLayer
...propsForMarkers
: the component will also receive the properties ofpropsForMarkers
as props
propsForMarkers
: props to pass on to marker components
Example
To try the example:
- Clone this repository
- run
npm install
in the root of your cloned repository - run
npm run example
- Visit localhost:8000