Setting the tile size in WMS layers
The OpenLayers.Layer.Grid
class is a special kind of layer, which divides the layer in different zoom levels composed of a grid of tiles.
The
OpenLayers.Layer.WMS
class is a subclass of the preceding one and, in addition to working in single tile mode, it can work in tiled mode as well.
Of course, controlling the size of the tiles of the WMS request can affect the performance. By default, the tile size is 256 x 256 pixels, but we can set this to any desired value. Bigger tile sizes means less request to the server but more computation time to generate a bigger image. On the contrary, smaller tile sizes means more server requests and less time to compute smaller images.
How to do it...
To set the tile size, perform the following steps:
Create an HTML file with OpenLayers library dependency.
Add a
div
element that will hold the map, as follows:<!-- Map DOM element --> <div id="ch2_tilesize" style="width: 100%; height: 100%;"></div>
Next, initialize...