I tryed use default WMTS layer with GeoServer source. Code looks like that:

      var projection = ol.proj.get('EPSG:3857');
      var projectionExtent = projection.getExtent();
      var size = ol.extent.getWidth(projectionExtent) / 256;
      var resolutions = new Array(10);
      var matrixIds = new Array(10);
      for (var z = 1; z < 10; ++z) {
          // generate resolutions and matrixIds arrays for this WMTS
          resolutions[z] = size / Math.pow(2, z);
          matrixIds[z] = z;
      const wmts_osm = new ol.source.WMTS({
        url: 'http://local:8080/geoserver/gwc/service/wmts',
              layer: 'workspace:test_CFD_layerset',
              matrixSet: 'geogrid4CFD',
              format: 'image/png',

              tileGrid: new ol.tilegrid.WMTS({
                        origin: ol.extent.getTopLeft(projectionExtent),
                        resolutions: resolutions,
                        matrixIds: matrixIds
              style: 'default',
              wrapX: true

      var wmtslayer = new ol.layer.Tile({
        source: wmts_osm

but WMTS requests in Chrome debuger are 400:

<ExceptionText>Unknown TILEMATRIX 6</ExceptionText>

What is the problem?


Your matrix is almost certainly not called just 6, if you look in the GetCapabilities response from GeoServer you will see a list of available matrix sets like this:


So once you know what your TileMatrixSet is called (possibly geogrid4CFD in your code) you can work out what the TileMatrixs are called, in this example EPSG:4326:0.

So it looks like you need to append the tile set name and a : to the number you store in matrixIds.

  • Yes. just change ``` matrixIds[z] = z ``` -> ``` matrixIds[z] ='geogrid4CFD:' z ``` – Tyomik_mnemonic Aug 14 '19 at 7:58

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.