Class: TileGrid

ol/tilegrid/TileGrid~TileGrid


import TileGrid from 'ol/tilegrid/TileGrid';

Base class for setting the grid pattern for sources accessing tiled-image servers.

new TileGrid(options)

tilegrid/TileGrid.js, line 53
Name Type Description
options

Tile grid options.

Name Type Default Description
extent module:ol/extent~Extent

Extent for the tile grid. No tiles outside this extent will be requested by module:ol/source/Tile sources. When no origin or origins are configured, the origin will be set to the top-left corner of the extent.

minZoom number 0

Minimum zoom.

origin module:ol/coordinate~Coordinate

The tile grid origin, i.e. where the x and y axes meet ([z, 0, 0]). Tile coordinates increase left to right and upwards. If not specified, extent or origins must be provided.

origins Array.<module:ol/coordinate~Coordinate>

Tile grid origins, i.e. where the x and y axes meet ([z, 0, 0]), for each zoom level. If given, the array length should match the length of the resolutions array, i.e. each resolution can have a different origin. Tile coordinates increase left to right and upwards. If not specified, extent or origin must be provided.

resolutions Array.<number>

Resolutions. The array index of each resolution needs to match the zoom level. This means that even if a minZoom is configured, the resolutions array will have a length of maxZoom + 1.

sizes Array.<module:ol/size~Size>

Sizes.

tileSize number | module:ol/size~Size

Tile size. Default is [256, 256].

tileSizes Array.<module:ol/size~Size>

Tile sizes. If given, the array length should match the length of the resolutions array, i.e. each resolution can have a different tile size.

Subclasses

Methods

forEachTileCoord(extent, zoom, callback)

tilegrid/TileGrid.js, line 195

Call a function with each tile coordinate for a given extent and zoom level.

Name Type Description
extent module:ol/extent~Extent

Extent.

zoom number

Integer zoom level.

callback function

Function called with each tile coordinate.

getMaxZoom(){number}

tilegrid/TileGrid.js, line 252

Get the maximum zoom level for the grid.

Returns:
Max zoom.

getMinZoom(){number}

tilegrid/TileGrid.js, line 261

Get the minimum zoom level for the grid.

Returns:
Min zoom.

getOrigin(z){module:ol/coordinate~Coordinate}

tilegrid/TileGrid.js, line 271

Get the origin for the grid at the given zoom level.

Name Type Description
z number

Integer zoom level.

Returns:
Origin.

getResolution(z){number}

tilegrid/TileGrid.js, line 285

Get the resolution for the given zoom level.

Name Type Description
z number

Integer zoom level.

Returns:
Resolution.

getResolutions(){Array.<number>}

tilegrid/TileGrid.js, line 294

Get the list of resolutions for the tile grid.

Returns:
Resolutions.

getTileCoordExtent(tileCoord, opt_extent){module:ol/extent~Extent}

tilegrid/TileGrid.js, line 374

Get the extent of a tile coordinate.

Name Type Description
tileCoord module:ol/tilecoord~TileCoord

Tile coordinate.

extent module:ol/extent~Extent

Temporary extent object.

Returns:
Extent.

getTileCoordForCoordAndResolution(coordinate, resolution, opt_tileCoord){module:ol/tilecoord~TileCoord}

tilegrid/TileGrid.js, line 396

Get the tile coordinate for the given map coordinate and resolution. This method considers that coordinates that intersect tile boundaries should be assigned the higher tile coordinate.

Name Type Description
coordinate module:ol/coordinate~Coordinate

Coordinate.

resolution number

Resolution.

tileCoord module:ol/tilecoord~TileCoord

Destination module:ol/tilecoord~TileCoord object.

Returns:
Tile coordinate.

getTileCoordForCoordAndZ(coordinate, z, opt_tileCoord){module:ol/tilecoord~TileCoord}

tilegrid/TileGrid.js, line 484

Get a tile coordinate given a map coordinate and zoom level.

Name Type Description
coordinate module:ol/coordinate~Coordinate

Coordinate.

z number

Zoom level.

tileCoord module:ol/tilecoord~TileCoord

Destination module:ol/tilecoord~TileCoord object.

Returns:
Tile coordinate.

getTileSize(z){number|module:ol/size~Size}

tilegrid/TileGrid.js, line 505

Get the tile size for a zoom level. The type of the return value matches the tileSize or tileSizes that the tile grid was configured with. To always get an module:ol/size~Size, run the result through module:ol/size~Size.toSize().

Name Type Description
z number

Z.

Returns:
Tile size.

getZForResolution(resolution, opt_direction){number}

tilegrid/TileGrid.js, line 533
Name Type Description
resolution number

Resolution.

direction number

If 0, the nearest resolution will be used. If 1, the nearest lower resolution will be used. If -1, the nearest higher resolution will be used. Default is 0.

Returns:
Z.