Open bishoym opened 3 years ago
You can provide deck.gl layers callbacks for changing how things are rendered. If you pass _subLayerProps
to EditableGeoJsonLayer
. And in those props, you can pass something like this:
const [myFeatures, setMyFeatures] = React.useState(...);
const layer = EditableGeoJsonLayer({
_subLayerProps: {
geojson: {
getLineColor: (feature) => {
if (myFeatures.features.indexOf(feature) === INDEX_YOU_WANT_TO_HIDE) {
return TRANSPARENT_COLOR;
} else {
return NORMAL_COLOR;
}
}
});
Forgive any typos. That pseudocode is from memory. You can look at the API docs for deck.gl's GeoJsonLayer for the available props that control rendering (it may be getLineColor
or maybe something else).
@ibgreen may also have a better solution than that.
@supersonicclay yup, I've gotten quite familiar with the API surface of this particular class over the last couple of months 😅 and I've implemented your suggestion.
Good news is: It technically works. Bad news is: it's hacky and requires a refactor of vertex styling in order to avoid having a set of floating vertices in EditMode.
Also, more crucially, it doesn't stop me from picking the layer which is unfortunately where I have to determine the solution as insufficient.
Like I said, I need access to the visible
prop and that unfortunately doesn't support a callback.
I know we can extend the EditableGeoJSONLayer
class, can you provide guidance as to how I might go about overriding the top-level visible
prop from boolean to a callback which iterates over the underlying features?
bishoym - did you find a solution? I am having a similar issue.
The DeckGL docs recommend using the visibility prop where frequent toggling of data is necessary.
If I'm using the
EditableGeoJSONLayer
, and passing it aFeatureCollection
, is there a way to access thisvisible
prop on a specific feature within the features array (by index)?The visible prop at the top level toggles the entire Layer - and therefore all the features simultaneously. That's not quite the desired behaviour. Any help is much appreciated!
@supersonicclay