Hi, I have a tif (and tfw) map that I want to be able to use offline (QML).
I have managed to load the tif as a raster layer on top of an online map, but I want to avoid it.
I I try to remove the BasemapImagery {}, the raster doesn't load...
In addition, how do I load the tfw file?
This is my code:
ApplicationWindow {
id: appWindow
width: 850
height: 650
title: "MapsProj"
Rectangle {
id: rootRectangle
clip: true
width: 800
height: 600
property real scaleFactor: System.displayScaleFactor
property var rasterLayer: null
property string rasterFilePath: "file:///C:/Projects/Sample/Maps/map1.tif"
MapView {
id: mapView
anchors.fill: parent
Map {
id: map
BasemapImagery {}
RasterLayer {
Raster {
path: ""
}
onLoadStatusChanged: {
if (loadStatus !== Enums.LoadStatusLoaded)
return;
mapView.setViewpointCenterAndScale(fullExtent.center, 80000);
}
}
}
}
Rectangle {
visible: addButton.visible
anchors.centerIn: addButton
radius: 8 * rootRectangle.scaleFactor
height: addButton.height + (16 * rootRectangle.scaleFactor)
width: addButton.width + (16 * rootRectangle.scaleFactor)
color: "lightgrey"
border.color: "darkgrey"
border.width: 2 * rootRectangle.scaleFactor
opacity: 0.75
}
Button {
id: addButton
anchors {
bottom: parent.bottom
horizontalCenter: parent.horizontalCenter
margins: 32 * rootRectangle.scaleFactor
}
text: "Add Raster"
onClicked: {
rootRectangle.createAndAddRasterLayer(rootRectangle.rasterFilePath)
}
}
function createAndAddRasterLayer(rasterUrl) {
var newRaster = ArcGISRuntimeEnvironment.createObject("Raster", {path: rasterUrl});
rasterLayer = ArcGISRuntimeEnvironment.createObject("RasterLayer", {raster: newRaster});
rasterLayer.loadStatusChanged.connect(zoomToRaster);
map.operationalLayers.clear();
map.operationalLayers.append(rasterLayer);
}
function zoomToRaster(){
if (rasterLayer === null)
return;
if (rasterLayer.loadStatus !== Enums.LoadStatusLoaded)
return;
mapView.setViewpointCenterAndScale(rasterLayer.fullExtent.center, 80000);
}
}
}