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

RVectorLayer - change url and refresh layer #66

Closed
chilli-andrew opened this issue May 31, 2022 · 2 comments
Closed

RVectorLayer - change url and refresh layer #66

chilli-andrew opened this issue May 31, 2022 · 2 comments

Comments

@chilli-andrew
Copy link

Hi,

I have been trying to plot an area using the RVectorLayer. I can get this to work nicely if the when the map loads for the first time but even after changing the url I am unable to get the refresh to work. So far I have the following working.

Given a coordinate I can load the map
Given a valid url to the wms service layer I can get the RVectorLayer to display
Given the coordinate changes I can get the RMap to reload at the new coordinate using [view, setView]
I can use a ref to the RVectorLayer to clear the existing source
What I haven't managed to work out is what I need to do to trigger the load with the new URL in place. The refresh method on the RVectorLayer is not working for me.

Any help would be much appreciated.

@mmomtchev
Copy link
Owner

RVectorLayer.refresh() is not a public method and has a different meaning from source.refresh() in OpenLayers.

Reusing a source has practically no performance benefit at all - it would be the same if you removed the layer and added a new one. You can add a key= property an update it every time you change the URL - this way React will recreate this layer.
Maybe I should add this into rlayer too - transparently replacing the source every time the URL changes.

mmomtchev added a commit that referenced this issue May 31, 2022
Clear the already loaded tiles when the URL property changes

Refs: #66
@chilli-andrew
Copy link
Author

Hi,

Thanks for the quick response. I added a key and that worked perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants