import TileInfo from "@arcgis/core/layers/support/TileInfo.js";const TileInfo = await $arcgis.import("@arcgis/core/layers/support/TileInfo.js");- Inheritance:
- TileInfo→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 4.0
Contains information about the tiling scheme for TileLayers, ElevationLayers, ImageryTileLayers, VectorTileLayers, and WebTileLayers.
TileInfo defines properties such as tile format, the level of details (LOD) at which the cache has tiles, the size of the tiles in pixels, and the screen resolution for which the tiles are intended to be most commonly displayed.
Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
declaredClass readonly inherited | ||
| | ||
| | ||
isWrappable readonly | | |
LOD[] | | |
| | ||
| | ||
| |
dpi
- Type
- number
The dots per inch (DPI) of the tiling scheme. If a DPI is chosen that does not match the resolution of the output device, the scale of the map tile will appear incorrect. The default value is 96.
- Default value
- 96
isWrappable
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 4.5
Indicates if the tiling scheme supports wrap around.
spatialReference
- Type
- SpatialReference
The spatial reference of the tiling schema.
Methods
create
- Signature
-
create (options?: TileInfoCreateOptions): TileInfo
A convenience method used to create a new TileInfo instance with preset properties like lods. Optionally, properties such as size, scales[], and a [SpatialReference](https://developers.arcgis.com/javascript/latest/references/core/geometry/SpatialReference/) can also be set to calculate lods for each TileInfo. This is useful in cases where the default amount of LODs provided are not sufficient. For example, if wanting to set the view's scale 1
- See also
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| options | An object that contains the size, scales, and/or SpatialReference used to compute the new TileInfo instance. | |
Examples
// This snippet shows how to create a TileInfo instance using the default// settings and passing its resulting LODs to a MapView's constraints
let view = new MapView({ container: "viewDiv", map: map, constraints: { lods: TileInfo.create().lods }});// This snippet shows how to set the MapView scale 1:1 while generating additional LODs for the MapView.constraints.const spatialReference = new SpatialReference({ wkid: 2154});
const center = new Point({ x: 0, y: 0, spatialReference});
// Create LODs from level 0 to 31const tileInfo = TileInfo.create({ spatialReference, numLODs: 32});
const lods = tileInfo.lods;
let view = new MapView({ container: "viewDiv", map, scale: 1, center, spatialReference, constraints: { lods: lods, snapToZoom: false }}); fromJSON
- Signature
-
fromJSON (json: any): any
Creates a new instance of this class and initializes it with values from a JSON object
generated from an ArcGIS product. The object passed into the input json
parameter often comes from a response to a query operation in the REST API or a
toJSON()
method from another ArcGIS product. See the Using fromJSON()
topic in the Guide for details and examples of when and how to use this function.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| json | A JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects. | |
- Returns
- any
Returns a new instance of this class.
scaleToZoom
- Signature
-
scaleToZoom (scale: number): number
Utility method used to convert a scale value to its corresponding zoom value.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| scale | The scale value to convert. | |
- Returns
- number
The returned zoom value.
Example
// get the zoom value for the vector tile layer at the given scale// then set the view.zoom to match layer's zoom level.view.when(function(){ view.zoom = layer.tileInfo.scaleToZoom(9027);}); toJSON
- Signature
-
toJSON (): any
Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.
- Returns
- any
The ArcGIS portal JSON representation of an instance of this class.
zoomToScale
- Signature
-
zoomToScale (zoom: number): number
Utility method used to convert a zoom value to its corresponding scale value.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| zoom | The zoom value to convert. | |
- Returns
- number
The returned scale value.
Example
// get the scale value for the vector tile layer at the view zoom level// then set the view.scale to match layer's scale.view.when(function(){ view.scale = vectorLayer.tileInfo.zoomToScale(view.zoom);});Type definitions
Format
Image format of the cached tiles.
- Type
- "png" | "png8" | "png24" | "png32" | "jpg" | "dib" | "tiff" | "emf" | "ps" | "pdf" | "gif" | "svg" | "svgz" | "mixed" | "lerc" | "lerc2d" | "raw" | "pbf"
TileInfoCreateOptions
Defines the size, scales, and/or SpatialReference used to generate a new TileInfo instance, and is used with the create() method.
spatialReference
- Type
- SpatialReference | undefined
The spatial reference
for the new TileInfo instance. If the spatial reference is not SpatialReference.WGS84 nor SpatialReference.WebMercator,
the origin of the TileInfo is 0.0.
- Default value
- WebMercator
scales
An array of scale values to use for the TileInfo. If none are specified, the scales from the ArcGIS Online basemaps are used from level 0 through 24.
- Default value
- The scales provided by ArcGIS Online basemaps