Open ptondereau opened 7 years ago
Looks like LayerGroup
from react-leaflet-universal
works not as expecting and MarkerClusterGroup
component that extends it doesn't receive leaflet map object through props.
To use .addLayer(this.leafletElement);
you need to get leafletElement
(object crerated by leaflet lib) of the map, that is why I'm using:
export default class MarkerClusterGroup extends LayerGroup {
By extending extends LayerGroup
react-leaflet gives me access to the leafletElement
of the map...
I didn't investigate another way of getting it.
P.S: maybe try to ask react-leaflet-universal
how they are getting leaflet object of the map inside custom classes?
@wmertens Do you have an example of leaflet working with react-imported-component? I can't seem to get it working.
react-leaflet-universal isn't working with the google maps library
@owlyowl I am not SSRing in this project, so no. I just pointed out the possibility. I'm also not using Google with leaflet. It should just work.
I'm in situation where I need to render to null this component when
window
global is not present (because of SSR). I use this lib to avoid error in SSR node server --> https://github.com/masotime/react-leaflet-universalI've forked your repo to change
LayerGroup
import origin and added same logic of render present in react-leaflet-universal but I don't really understand the API. Indeed, an error is throw aboutthis.container.map
is undefined so I can't access to the container.Any clue for how to achieve this?
Here is my snippet: