Class: TileGrid

ol.tilegrid.TileGrid


import TileGrid from 'ol/tilegrid/tilegrid';

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

new ol.tilegrid.TileGrid(options)

src/ol/tilegrid/tilegrid.js, line 23
Name Type Description
options

Tile grid options.

Name Type Description
extent ol.Extent | undefined

Extent for the tile grid. No tiles outside this extent will be requested by 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 | undefined

Minimum zoom. Default is 0.

origin ol.Coordinate | undefined

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.<ol.Coordinate> | undefined

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. Required.

tileSize number | ol.Size | undefined

Tile size. Default is [256, 256].

tileSizes Array.<(number|ol.Size)> | undefined

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)

src/ol/tilegrid/tilegrid.js, line 169

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

Name Type Description
extent ol.Extent

Extent.

zoom number

Integer zoom level.

callback function

Function called with each tile coordinate.

getMaxZoom(){number}

src/ol/tilegrid/tilegrid.js, line 229

Get the maximum zoom level for the grid.

Returns:
Max zoom.

getMinZoom(){number}

src/ol/tilegrid/tilegrid.js, line 239

Get the minimum zoom level for the grid.

Returns:
Min zoom.

getOrigin(z){ol.Coordinate}

src/ol/tilegrid/tilegrid.js, line 250

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

Name Type Description
z number

Integer zoom level.

Returns:
Origin.

getResolution(z){number}

src/ol/tilegrid/tilegrid.js, line 265

Get the resolution for the given zoom level.

Name Type Description
z number

Integer zoom level.

Returns:
Resolution.

getResolutions(){Array.<number>}

src/ol/tilegrid/tilegrid.js, line 275

Get the list of resolutions for the tile grid.

Returns:
Resolutions.

getTileCoordExtent(tileCoord, opt_extent){ol.Extent}

src/ol/tilegrid/tilegrid.js, line 361

Get the extent of a tile coordinate.

Name Type Description
tileCoord ol.TileCoord

Tile coordinate.

extent ol.Extent

Temporary extent object.

Returns:
Extent.

getTileCoordForCoordAndResolution(coordinate, resolution, opt_tileCoord){ol.TileCoord}

src/ol/tilegrid/tilegrid.js, line 384

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 ol.Coordinate

Coordinate.

resolution number

Resolution.

tileCoord ol.TileCoord

Destination ol.TileCoord object.

Returns:
Tile coordinate.

getTileCoordForCoordAndZ(coordinate, z, opt_tileCoord){ol.TileCoord}

src/ol/tilegrid/tilegrid.js, line 476

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

Name Type Description
coordinate ol.Coordinate

Coordinate.

z number

Zoom level.

tileCoord ol.TileCoord

Destination ol.TileCoord object.

Returns:
Tile coordinate.

getTileSize(z){number|ol.Size}

src/ol/tilegrid/tilegrid.js, line 499

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 ol.Size, run the result through ol.size.toSize().

Name Type Description
z number

Z.

Returns:
Tile size.

getZForResolution(resolution, opt_direction){number}

src/ol/tilegrid/tilegrid.js, line 529
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.