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

Refreshing a reprojected XYZ source not working #11326

Open
umbertodistaso opened this issue Jul 27, 2020 · 12 comments
Open

Refreshing a reprojected XYZ source not working #11326

umbertodistaso opened this issue Jul 27, 2020 · 12 comments

Comments

@umbertodistaso
Copy link

umbertodistaso commented Jul 27, 2020

Hello everyone,

Seems that refreshing a XYZ source (when e.g. some params are changing and we want to refresh the map) is not working anymore.

Here a small example, https://codesandbox.io/s/ol-xyzsource-dx2g0?file=/main.js

As you can see by the network monitor, by clicking the "refresh xyz source" button the source is not refreshed since the monitor does not report any network activity.

@M393
Copy link
Contributor

M393 commented Jul 27, 2020

Your example works for me when I click the 'open in new window' button.

@umbertodistaso
Copy link
Author

umbertodistaso commented Jul 27, 2020

Your example works for me when I click the 'open in new window' button.

????

Sorry, i didn't understand your reply or maybe I haven't explained the issue properly.

The issue here is that the XYZ source is not refreshed invoking the source.refresh() function called by the button.

You can see a "flashing" effect but is you are looking at the network monitor tiles aren't re-downloaded. This feature was working in 5.X.

From the doc https://openlayers.org/en/latest/apidoc/module-ol_source_Source-Source.html#refresh

Refreshes the source. The source will be cleared, and data from the server will be reloaded.

ol

@M393
Copy link
Contributor

M393 commented Jul 27, 2020

I clicked this button, to open the map in a new tab, then it works.
image
Of course the case above needs to work also.

@umbertodistaso
Copy link
Author

mhhhh.....
also tried in a new tab as you suggested but still nothing. Tested with Chrome and Firefox

ol_tab

@ahocevar
Copy link
Member

The tiles you want to refresh are in the browser cache. This is why no new requests are sent. Click "Disable cache" in your developer tools and try again. Then you'll see that the tiles are requested again.

@umbertodistaso
Copy link
Author

Ok maybe i've used the wrong example to show the issue. I'm writing a new codepen example.
The tile URL (for the same tile) is changing because some params used to generate the img on server side was changed, but i cannot see any new image downloaded from the network.

I'm coming back with the new example

@umbertodistaso
Copy link
Author

Sorry for the delay, when i was trying to write a complete example I notice that projections was declared only on sources and not on the main view. By declaring the right projection when initializing the view everything works.

This wasn't necessary in 5.X but anyway now is working

@ahocevar
Copy link
Member

I think it is still worth investigating this further. If your sources have a different projection than your view, they will be reprojected to the view projection. If you specify the same projection in the view, the source will be used directly. So what you are experiencing might be a problem with reprojected layers.

@umbertodistaso
Copy link
Author

Ok, anyway if could be useful here the example https://codesandbox.io/s/refresh2-yejq9?file=/main.js

@mike-000
Copy link
Contributor

If you specify a custom projection for the layers and use the default projection for the view you would need to define transforms or a proj4 definition for the custom projection. With everything using the custom projection that isn't necessary. You could also reduce your tileUrlFunction to one statement using

return (
    base +
    "&$extent=" +
    tilegrid.getTileCoordExtent(tileCoord).toString()
);

@umbertodistaso
Copy link
Author

Sorry for the messy code but i had to rewrite the entire example since i'm using OL via GWT.

In any case i will try your hint, thanks!

@ahocevar ahocevar changed the title Refreshing a XYZ source not working in 6.4.0 Refreshing a reprojected XYZ source not working Jul 29, 2020
@ahocevar
Copy link
Member

I was now able to verify that this only happens on reprojected sources. It is not a regression, it never worked. Here is a codesandbox to reproduce the issue: https://codesandbox.io/s/purple-meadow-dws3l?file=/main.js. Open the console in the codesandbox to see what is going on. When the projection of the View is removed, i.e. reprojection is off, refresh() works as expected.

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

No branches or pull requests

4 participants