4

I'm trying to set up a TileWMS layer in OpenLayers 3 as:

var baseMap = new ol.layer.Tile({
    title: "MayBase Map",
    source: new ol.source.TileWMS({
        url: mapUrl,
        params: {
            'LAYERS': 'GIS_Demo', 
            'TILED':     true,
            'SRS':'EPSG:900913',
            'WIDTH':256,
            'HEIGHT':256},
        serverType: 'geoserver'
     })
 });

But when I actually request I get the URL like:

http://localhost:8080/geoserver/gwc/service/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image/png&TRANSPARENT=true&LAYERS=GIS_Demo&TILED=true&SRS=EPSG:900913&WIDTH=205&HEIGHT=205&CRS=EPSG:3857&STYLES=&FORMAT_OPTIONS=dpi:81&BBOX=8624542.775473006,1452915.0336446315,8629434.745283257,1457807.003454883

Here even though I am setting the height and width of 256 each its somehow overriding the default values of 205 (for more view docs).

This is basically causing the GWC error as : 400: The requested tile dimensions 205x205 do not match those of the grid set (256x256)

Why is this happening? is this a bug? or is there any other way of specifying the width and height?

7

I had similar problem, adding

 pixelRatio: 1,

to ol.Map section solved the problem.

http://jsfiddle.net/jLmyo3gL/2/

0

If you look at the http://openlayers.org/en/v3.6.0/apidoc/ol.source.TileWMS.html documentation carefully, at the end of the params option it says

WIDTH, HEIGHT, BBOX and CRS (SRS for WMS version < 1.3.0) will be set dynamically.

To change your tile dimensions you need to set the a tilegrid to the tilegrid option, but 256x256 is the default so you can just leave that option out.

var baseMap = new ol.layer.Tile({
    title: "MayBase Map",
    source: new ol.source.TileWMS({
        url: mapUrl,
        params: {'LAYERS': 'GIS_Demo', 'TILED': true,'SRS':'EPSG:900913'},
        serverType: 'geoserver'
      })
  });
  • sorry for late reply, but i have tried what u suggested by default. And with it the request as usual takes 205x205 as tile size. That's the reason why i have provided the explicit option for tile size which is unfortunately not working. – Suraj Jun 16 '15 at 12:01
  • 1
    @Suraj are you able to put your code up on a jsfiddle.net? You can hit the Create JSFiddle button from openlayers.org/en/v3.6.0/examples/wms-tiled.html?q=TileWMS as a starting point – Guy Jun 16 '15 at 12:17
  • I have also same problem,here i am giving code jsfiddle.net/seema30/gtmq47sq/1 please help me. – Seema Barate Jul 18 '17 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.