I'm trying to visualize data from supabase onto KeplerGl map but KeplerGl keeps on duplicating layers upon adding new data to the map.
When I set keepExistingConfig: false
it wipes all the existing layers and adds the last fetched datasets.
I kindly need some help on this task.
Here is my keplergl map
In AddDataToMap.js
file, same as AddPoints
and AddMonitoringDeviceStatus
files
const ADD = () => {
const data = fetch('from/some/endpoint');
const geojson = {
datasets: { info: {id: 'my_data'},data: processGeojson(data) }
options: { keepExistingConfig: true },
... // other configs
}
useEffect(()=>{
dispatch(addDataToMap(geojson))
});
return null;
}
In map.js
file
const Map = () => (
<ErrorBoundary>
<AutoSizer>
{({ height, width }) => (
<KeplerGl
id="map"
store={store}
width={width}
height={height}
mapboxApiAccessToken={token}
onHover={handleLayerHover}
onClick={handleLayerClick}
/>
)}
</AutoSizer>
</ErrorBoundary>
<AddDataToMap />
<AddPoints />
<AddMonitoringDeviceStatus />
)