0

I am trying to change the tile size for my TileLayer in openlayers and I have not been able to change it. No matter what I set the tileSize to be it is always [256,256]. Also, The files I am getting from local_url is 1900x1268. Below is the code.

var projection = get('EPSG:4326');
local_url = 'assets/tile/{z}/{x}/{y}.png';

map = new Map({
  target: 'map',
  layers: [
    new TileLayer({
      source: new XYZ({
        url: this.local_url,
        projection: projection,
        wrapX: false,
        tileSize: [1024,1024]
      })
  ],
  view: new View({
    center: [0,0],
    zoom:0,
    minZoom: 0,
    maxZoom: 5,
    projection: projection
  })
});
Ashim
  • 877
  • 2
  • 12
  • 22
  • You are probably seeing the tiles at the wrong zoom level so they will appear compressed. See this example https://openlayers.org/en/latest/examples/xyz-esri-4326-512.html – Mike Jul 17 '19 at 10:30
  • what do you mean by wrong zoom level ? The XYZ source that i am using, I can only have 1 image at zoom level 0, x=0,y=0 right ? I am trying to increase the size of that image but it is not letting me exceed 256*256 – Ashim Jul 18 '19 at 01:42
  • In an EPSG:4326 grid the width is 2 x the height and there are usually 2 tiles at zoom 0 https://services.arcgisonline.com/arcgis/rest/services/ESRI_Imagery_World_2D/MapServer/tile/0/0/0 https://services.arcgisonline.com/arcgis/rest/services/ESRI_Imagery_World_2D/MapServer/tile/0/0/1 – Mike Jul 18 '19 at 08:30
  • So there is no way to customize the tile size ? I can only have it 256*256 ? – Ashim Jul 22 '19 at 02:30
  • Yes, see the example I linked in the first comment https://openlayers.org/en/latest/examples/xyz-esri-4326-512.html – Mike Jul 22 '19 at 08:05

0 Answers0