Monday 30 January 2017

javascript - Limit ImageWMS request size



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.



Answer



Solution 1 - Stretch



  1. Custom loader

  2. If the image is larger than 2048px, store originalWidth and originalHeight and request image with min(2048, original[Width|Height]).

  3. Draw requested image into a canvas with size (originalWidth, originalHeight)

  4. Set canvas data as src for Image


Solution 2 - Tile




  1. Use TileWMS with a tile grid of 2048px sized tiles

  2. Recreate source and tile grid everytime projection changes


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...