Hi,
I am using ImageTiledLayer to display raster tiles stored in local filesystem. All works fine. Now sometimes I need to download only some tiles (still fine) and for the tiles which are not in the filesystem show some "No Data" tile.
I tired the following approaches:
1. Set noDataTileBehavior : Enums.NoDataTileBehaviorShow This has no effect at all. I suspect I need to provide a special NoData tile but I don't know how to get it and how to tell the layer about it. When the provided file is simply no there, the tile is empty.
2. Check file existence and if the file does not exist provide my own special No Data tile. This would be good as I could customize the tile. But! The tileCallback function does not pass beyond the file existence check! No error, no logging afterwards. I have tried both pure JS way and Qt way. No success.
Is there any working way to achieve what I am trying to do? Thanks in advance for any help!
Solved! Go to Solution.
You could use FileInfo object to check if the file exists in the callback, and if not, display some other image. Here is an example:
import QtQuick 2.6
import QtQuick.Controls 2.2
import Esri.ArcGISRuntime 100.6
import Esri.ArcGISExtras 1.1
ApplicationWindow {
id: appWindow
width: 800
height: 600
MapView {
anchors.fill: parent
Map {
Basemap {
id: basemapFilePrefix
onErrorChanged: console.log("Basemap error: " + error.message + " (" + error.additionalMessage + ")");
SpatialReference {
wkid: 4326
}
ImageTiledLayer {
id: customTiledLayerFilePrefix
onErrorChanged: console.log("ImageTiledLayer error: " + error.message + " (" + error.additionalMessage + ")");
fullExtent: Envelope {
spatialReference: SpatialReference { wkid: 3857 }
xMin: -20037508.342789244
xMax: 20037285.703807656
yMin: -20037471.205137063
yMax: 20037471.205137063
}
noDataTileBehavior: Enums.NoDataTileBehaviorShow
tileInfo: TileInfo {
dpi: 96
format: Enums.TileImageFormatJPG
origin: Point {
spatialReference: SpatialReference { wkid: 3857 }
x: -20037508.342789244
y: 20037508.368847027
}
spatialReference: SpatialReference { wkid: 3857 }
LevelOfDetail {
level: 0
resolution: 156543
scale: 591658000
}
LevelOfDetail {
level: 1
resolution: 78271.5
scale: 295829000
}
LevelOfDetail {
level: 2
resolution: 39135.8
scale: 147914000
}
tileHeight: 256
tileWidth: 256
}
tileCallback: function(level, row, column) {
var localUrl = System.userHomePath + "/ArcGIS/Runtime/UnitTests/tiledata/" + level + "-" + row + "-" + column + ".jpg";
fileInfo.filePath = localUrl.substring(7);
if (fileInfo.exists) {
return localUrl;
} else {
return System.userHomePath + "/ArcGIS/Runtime/UnitTests/tiledata/nodata.jpg";
}
}
}
}
}
}
FileInfo {
id: fileInfo
}
}
That helped, thank you.
Michal