Is there any built-in way of limiting the request width/height of ImageWMS sources and have the map just scale the image up to fill the extent? I'm building an application that includes a bunch of WMS providers that don't support resolutions higher than 2048.
-
it depends on the client application you are using - but try using tiles to avoid these issues.– Ian Turton ♦Mar 17, 2017 at 8:40
-
You want to reduce or increase this value? There is a limit to all the wms max tile size. For e.g. MS4W supports max 2048 pixels tile size. Which WMS server you are using?– GeoSpatialEarth.inMar 18, 2017 at 18:33
-
I want (if possible), for ex. if OpenLayers tries to request a 3000x1000 image, request a 2048x1000 image instead and stretch it. Maybe I could draw it into a canvas first and then set the Image src. I think our end-client would rather have a blurry image than loading the map with tiles (which would be the best solution, I know.) I could also create a tile grid with 2048px sized tiles, but I'd have to recreate it every time the projection changes.– ThiattMar 19, 2017 at 1:52
1 Answer
Solution 1 - Stretch
- Custom loader
- If the image is larger than 2048px, store
originalWidth
andoriginalHeight
and request image withmin(2048, original[Width|Height])
. - Draw requested image
into a canvas with size
(originalWidth, originalHeight)
- Set canvas data as src for
Image
Solution 2 - Tile
- Use TileWMS with a tile grid of 2048px sized tiles
- Recreate source and tile grid everytime projection changes