Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught error 'source-id' is already added to the map #94

Open
lcoursey opened this issue Apr 20, 2021 · 0 comments
Open

Uncaught error 'source-id' is already added to the map #94

lcoursey opened this issue Apr 20, 2021 · 0 comments
Labels
question Further information is requested

Comments

@lcoursey
Copy link

lcoursey commented Apr 20, 2021

Uncaught error 'source-id' is already added to the map
I can trigger this error by toggling a rendered data source and layer. For example by toggling the value of showLayer off and on again:

const { showLayer } = props;

return (
    {showLayer 
        ?
        <AzureMapDataSourceProvider
              id={`source-id`}
              collection={someGeojson}
          >
          <AzureMapLayerProvider
              id={`layer-id`}
              options={{}}
              type='LineLayer'
          />
      </AzureMapDataSourceProvider> : null
    }
)

It looks like data source cleanup is not being done by react-azure-maps?

If I manually remove the source and layer in a cleanup useEffect:

useEffect(() => {
 return () => {
    map.layers.remove('layer'id');
    map.sources.remove('source-id);
}
}, []);

It fixes the error, but then I get further errors from the wrapper as it tries to remove the layers itself:
Error on remove layer Error: The layer 'layer-id' has not been added to the map and cannot be removed

@dubiety dubiety added the question Further information is requested label Jun 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants