geoadmin / ol3

OpenLayers 3
http://ol3js.org/
Other
11 stars 6 forks source link

Query Tiles outside map extent #150

Open hitschhiker opened 1 year ago

hitschhiker commented 1 year ago

Hi,

I work with ArcGIS JS API 4 and OL3 and load GeoAdmin-layers as WMTS-layers (TileLayers) Now I want to avoid the annoying 'http 400' messages in browser when non existing tiles were queried outside Switzerland. Setting the proper layer and map-extent [ 2420000, 1030000, 2900000, 1350000 ] does not seem to help...

Here a simple example

Do you know a better solution than restricting user navigation in the map (pan/zoom)?

Thanks for any feedback! Christian

fredj commented 1 year ago

Hi,

The map projection is in EPSG:3857, the extent should also be is this projection.

fredj commented 1 year ago

And you can restrict user navigation by setting an extent to the view: https://openlayers.org/en/latest/examples/extent-constrained.html

hitschhiker commented 1 year ago

Thanks for your reply. That was only an example for the errors in the browser. I use 'epsg:2056' with this extent this '2420000, 1030000, 2900000, 1350000'

I've implemented the OL View just like in your example: https://openlayers.org/en/latest/examples/extent-constrained.html ...and I get the browser errors for GeoAdmin-Layers when I pan or zoom to the edge of the extent

fredj commented 1 year ago

See https://codesandbox.io/s/stoic-bush-ty0s0l?file=/src/index.js

restrictedExtent is the extent in EPSG:3857 that is used to both restrict the user navigation (used in the view) and the downloaded data (used in the layer)

hope that helps

hitschhiker commented 1 year ago

Ok now it works for me. But only when I downsize the extent for the view so that panning cannot reach the inexistent tiles: EPSG:2056 extent basemap: [ 2420000, 1030000, 2900000, 1350000 ] (official extent GeoAdmin) extent of the view: [ 2430000, 1040000, 2890000, 1340000 ] (20km smaller in one dim)