alex3165 / react-leaflet-draw

React component for leaflet-draw on top of react-leaflet
228 stars 152 forks source link

using with GeoJSON #29

Closed drheinheimer closed 7 years ago

drheinheimer commented 7 years ago

I can use this with basic Leaflet features as in the example, but I cannot use it with the react-leaflet GeoJSON component. i.e.,

Works (from the example): <Circle center={[51.51, -0.06]} radius={200}/>

Doesn't work: <GeoJSON data={features} onEachFeature={setFeatureStyle}/> The error on editing is: "Uncaught TypeError: Cannot read property 'enable' of undefined". The GeoJSON loads into the map, I just can't edit with it. I need this, so will investigate and do a PR if I find a fix.

drheinheimer commented 7 years ago

Update: from the react-leaflet description of the data property of GeoJSON components:

This property will not be updated if it is changed after the component is mounted.

So the short term fix is to map GeoJSON parts into leaflet-draw components. I'll close, but keep these notes in case others have the same issue.

vjpr commented 7 years ago

So the short term fix is to map GeoJSON parts into leaflet-draw components

@rheinheimer This is problematic for me. I have 1000s of features I need to show, and I don't want to render them in react. Any other options?

drheinheimer commented 6 years ago

@vjpr Did you get your answer? Just use the non-React (jQuery) version of Leaflet. That's far more full featured anyway. On the other hand, I've had issues with so many features. If you need significant interactivity, I'm not sure the best option. But if just for displaying, I highly recommend Mapbox and their Studio toolkit.