Search code examples
openlayersopenlayers-3openlayers-5angular-openlayers

Tile Size remains the same as default which is [256,256] in OpenLayers


I am trying to add a custom layer using XYZ source on the Open Street Map. I want to add it to a certain coordinate. I want to change the tile size to a different value than the default value. I am not able to change the tile Size to any value. After numerous attempts I added tileGrid and it gives me Assertion Error. Am i missing something.

 let map = new Map({
    target: 'map-container',
    layers: [
        new TileLayer({
        source: new OSM()
        }),
    new TileLayer({
          source: new XYZ({
            url: 'assets/tile/{z}/{x}/{y}.png',
            wrapX: false,
            tileGrid: new TileGrid({
            tileSize: [1024,512]
          })                                                                                                                     
       }),
          tileSize: [1024,512]              

        })
      ],
      view: new View({
        projection: 'EPSG:3857',
        center: [0,0],
        zoom:0,
        minZoom: 0,
      })

Solution

  • The reason for this is because the files that i have were [256,256], to increase the size must have equal to greater to the size you want.