nebula.gl
nebula.gl copied to clipboard
Crash when edit polygon.
Describe
I am facing error when implement nebula.gl in react gl and typescript. I think its because when I change the featureCollection, it always re-render so many times.
Actual Result
Expected Result
Reproduce Steps
I try to solve by referene the editable class by useRef. However I can't use onEdit method.
Screenshots
This is my code :
editableLayerRef.current = new (EditableGeoJsonLayer as any)({
data: featureCollection,
mode: mode,
pickable: true,
autoHighlight: true,
modeConfig,
selectedFeatureIndexes,
onClick: (info) => {
setSelectedFeatureIndexes(info.object ? [info.index] : []);
},
onEdit: ({ updatedData }) => {
const newCollection: GeojsonFeatureCollection = updatedData;
setFeatureCollection(newCollection);
},
highlightColor: getHightLightColor(),
getLineColor: getLineColorForFeature(),
getFillColor: getFillColorForFeature(),
});
useEffect(() => {
geoJSONLayerRef.current = new GeoJsonLayer({
data: areaProjectFeatureCollection,
pickable: true,
autoHighlight: true,
highlightColor: getHightLightColor(),
lineWidthMinPixels: 3,
getLineColor: getLineColorForFeature(),
getFillColor: getFillColorForFeature(),
});
}, [areaProjectFeatureCollection]);
layerRef.current = [geoJSONLayerRef.current, editableLayerRef.current];
<DeckGL
initialViewState={INITIAL_VIEW_STATE}
controller={{ doubleClickZoom: false }}
layers={layerRef.current}
>
<Map
style={{ width: '100%', height: '100%' }}
mapStyle="mapbox://styles/mapbox/streets-v11"
mapboxAccessToken={process.env.REACT_APP_MAPBOX_ACCESS_TOKEN || ''}
ref={(ref) => setMapRef(ref)}
/>
</DeckGL>
To Do List
- [ ] Add label and assign to milestone
- [ ] Coding
- [ ] Test
Hey, I was just looking through the issue tracker and it is probably not related to the problem that you are having, plus this was from 29 days ago... but, I think you mean to do this:
highlightColor: getHightLightColor,
instead of this:
highlightColor: getHightLightColor(),
and same for all of the other accessors/callbacks.