A base class for layers that display cached maps. You would typically work with one or more sub-classes of this class. More...
Header: | #include <ImageTiledLayer.h> |
Since: | Esri::ArcGISRuntime 100.0 |
Inherits: | Esri::ArcGISRuntime::ImageAdjustmentLayer |
Inherited By: | Esri::ArcGISRuntime::ArcGISTiledLayer, Esri::ArcGISRuntime::ServiceImageTiledLayer, and Esri::ArcGISRuntime::WmtsLayer |
Public Functions
ImageTiledLayer(const Esri::ArcGISRuntime::TileInfo &tileInfo, const Esri::ArcGISRuntime::Envelope &fullExtent, QObject *parent = nullptr) | |
virtual | ~ImageTiledLayer() override |
Esri::ArcGISRuntime::NoDataTileBehavior | noDataTileBehavior() const |
virtual void | setAttribution(const QString &attribution) |
void | setNoDataTileBehavior(Esri::ArcGISRuntime::NoDataTileBehavior noDataTileBehavior) |
Esri::ArcGISRuntime::TileInfo | tileInfo() const |
Signals
void | cancelTileRequest(const Esri::ArcGISRuntime::TileKey &tileKey) |
void | tileRequest(const Esri::ArcGISRuntime::TileKey &tileKey) |
Protected Functions
void | setNoDataTile(const Esri::ArcGISRuntime::TileKey &tileKey) |
void | setTileData(const Esri::ArcGISRuntime::TileKey &tileKey, const QByteArray &data) |
void | setTileError(const Esri::ArcGISRuntime::TileKey &tileKey, const QString &error) |
Detailed Description
ImageTiledLayer defines a base class for layers that display tiled map services and cached image services. This is an abstract class that can be derived in a custom class to implement a local tile data scheme. To implement a custom ImageTiledLayer, for example to load your own local tile data, you should derive from this type and supply the data for each tile as it is requested. Additionally, you must supply TileInfo that describes the tiling scheme, and an Envelope that defines the layer extent.
Implement this class if you want to create a custom tiled layer where the cached images cannot be referenced by a simple URL. If your images can be referenced by a simple URL, you should instead implement ServiceImageTiledLayer.
Creating a custom image tiled layer
To implement your own custom ImageTiledLayer, for example to load your own local tile data, you should derive from this type and supply the data for each tile as it is requested.
This allows you to asynchronously generate a byte array (for example from an image file on the device) for each tile.
To do this, connect to the tileRequest signal and call one of the following protected methods for each TileKey which is requested:
Function | Description |
---|---|
setTileData | Sets the byte array corresponding to a tile request. |
setTileError | Sets the error corresponding to a tile request. |
setNoDataTile | If there is no data corresponding to a tile request. |
The tileInfo parameter defines the format of images (image format, DPI, width and height), and the limits of extent and scale factor for requests.
CustomTiledLayer::CustomTiledLayer(const TileInfo& tileInfo, const Envelope& fullExtent, QObject* parent) : ImageTiledLayer(tileInfo, fullExtent, parent) { connect(this, &CustomTiledLayer::tileRequest, this, [this](const TileKey& tileKey) { QString localUrl = tilesDataRoot() + QString("/tiledata/%1-%2-%3.jpg").arg( QString::number(tileKey.level()), QString::number(tileKey.row()), QString::number(tileKey.column())); QFile f(localUrl); if (!f.exists()) { sendMessage(QString("Cannot find: %1").arg(localUrl)); setNoDataTile(tileKey); } else if (!f.open(QIODevice::OpenModeFlag::ReadOnly)) { sendMessage(QString("Cannot open: %1").arg(localUrl)); setTileError(tileKey, QString("Cannot open: %1").arg(localUrl)); } else { setTileData(tileKey, f.readAll()); } }); }
You can also connect to the cancelTileRequest signal in order to terminate tile requests which are no longer required.
See also Layer, ServiceImageTiledLayer, ArcGISTiledLayer, WmtsLayer, WebTiledLayer, OpenStreetMapLayer, and TileInfo.
Member Function Documentation
[since Esri::ArcGISRuntime 100.2]
ImageTiledLayer::ImageTiledLayer (const Esri::ArcGISRuntime::TileInfo &tileInfo , const Esri::ArcGISRuntime::Envelope &fullExtent , QObject *parent = nullptr)
Creates an image tiled layer from the given tile metadata and the full extent.
- tileInfo - A tile info object.
- fullExtent - The full extent of the layer.
- parent - The optional parent QObject.
This function was introduced in Esri::ArcGISRuntime 100.2.
[override virtual]
ImageTiledLayer::~ImageTiledLayer ()
Destructor.
[signal, since Esri::ArcGISRuntime 100.2]
void ImageTiledLayer::cancelTileRequest (const Esri::ArcGISRuntime::TileKey &tileKey )
Signal emitted when a tile request is canceled.
- tileKey - The key used to identify the specific tile.
Note: : React to this signal when implementing your own custom image tiled layer type.
This function was introduced in Esri::ArcGISRuntime 100.2.
Esri::ArcGISRuntime::NoDataTileBehavior ImageTiledLayer::noDataTileBehavior () const
Controls how a tile request that returns 'NoData' is resampled.
Zooming in can result in tile requests with no tiles at the requested level of detail. In this case, there are options that control what to display where the tile should be including:
- NoDataTileBehavior::UpSample - Resample the pixels from a lower level of detail tile. This can result in pixelation or blurriness. This is the default behavior for operational layers.
- NoDataTileBehavior::Blank - The 'NoData' pixels will show the raster picture as being blank (or disappearing). This is the default behavior for basemap reference layers.
- NoDataTileBehavior::Show - This will show the raster picture with the text 'No Data' stamped over it once you pass the lowest level-of-detail scale.
Note: Sometimes, to see the effect on the map when setting the noDataTileBehavior property, the Layer::maxScale value must also be explicitly set. The Layer::maxScale property may need to be smaller than the level-of-detail setting that was used to create the tiled images in ArcGIS Pro or ArcGIS Desktop. For example, consider an operational image tile layer showing forest cover that was created with the level-of-detail assumption that it was to be viewed above a scale of 5000 (meaning you will not see 'NoData' until you zoom closer to the Earth than a 5000 scale). However, you want to be able to zoom in closer to the Earth surface, say down to 3000 or 300. By setting the Layer::maxScale property to a number smaller than 5000, you will be able to zoom in closer to the Earth and see the effects of changing the noDataTileBehavior enumerations.
See also setNoDataTileBehavior().
[virtual, since Esri::ArcGISRuntime 100.1]
void ImageTiledLayer::setAttribution (const QString &attribution)
Sets the attribution string for the image tiled layer.
- attribution - The attribution string.
This function was introduced in Esri::ArcGISRuntime 100.1.
[protected, since Esri::ArcGISRuntime 100.2]
void ImageTiledLayer::setNoDataTile (const Esri::ArcGISRuntime::TileKey &tileKey )
Specifies that there is no data corresponding to a tileKey.
Note: : This function should only be called when implementing your own custom image tiled layer type.
This function was introduced in Esri::ArcGISRuntime 100.2.
See also ImageTiledLayer::setTileData.
void ImageTiledLayer::setNoDataTileBehavior (Esri::ArcGISRuntime::NoDataTileBehavior noDataTileBehavior )
Sets the noDataTileBehavior to noDataTileBehavior.
See also noDataTileBehavior.
[protected, since Esri::ArcGISRuntime 100.2]
void ImageTiledLayer::setTileData (const Esri::ArcGISRuntime::TileKey &tileKey , const QByteArray &data)
Sets data corresponding to a tileKey.
Note: : This function should only be called when implementing your own custom image tiled layer type.
This function was introduced in Esri::ArcGISRuntime 100.2.
[protected, since Esri::ArcGISRuntime 100.2]
void ImageTiledLayer::setTileError (const Esri::ArcGISRuntime::TileKey &tileKey , const QString &error)
Sets an error corresponding to a tileKey.
Note: : This function should only be called when implementing your own custom image tiled layer type.
This function was introduced in Esri::ArcGISRuntime 100.2.
Esri::ArcGISRuntime::TileInfo ImageTiledLayer::tileInfo () const
Returns the tiling scheme information for this layer.
The value of tileInfo cannot be changed after this layer is loaded.
[signal, since Esri::ArcGISRuntime 100.2]
void ImageTiledLayer::tileRequest (const Esri::ArcGISRuntime::TileKey &tileKey )
Signal emitted when a tile is requested.
- tileKey - The key used to identify the specific tile.
Note: : React to this signal when implementing your own custom image tiled layer type.
This function was introduced in Esri::ArcGISRuntime 100.2.