Hi, i m now working with offline map, now i have to set initial extent of my map, i could not find any option anywheer
Solved! Go to Solution.
Please have the answer
MobileMapPackage {
id: mmpk
path: assetsPath + mapPackageFileName
onLoadStatusChanged: {
if (loadStatus !== Enums.LoadStatusLoaded) {
return;
}
if (mmpk.maps.length < 1) {
return;
}
mapView.map = mmpk.maps[0];
mapView.map.initialViewpoint = viewpoint;
}
onErrorChanged: {
console.log("Mobile Map Package Error: %1 %2".arg(error.message).arg(error.additionalMessage));
}
}
Hi @rsharma - if your Map is not yet loaded (for example you read it directly from a MobileMapPackage already on your device) you should be able to use void Map::setInitialViewpoint(const Esri::ArcGISRuntime::Viewpoint &viewpoint) before you set it on the MapView.
Another approach would be to use https://developers.arcgis.com/qt/latest/cpp/api-reference/esri-arcgisruntime-mapview.html or similar to set the position directly on the view.
Hope that helps,
Luke
I am using qml with js not cpp. does this fnc work for setting extent setViewpointGeometry
i m trying like this on offline map, but could not get success to set initial view point. Any help would be great from your end. Thanks in advance.
MapView {
id:mapView
property real initialMapRotation: 0
Map {
initialViewpoint: viewpoint
}
Component.onCompleted: {
mmpk.load()
}
anchors {
left: parent.left
right: parent.right
top: parent.top
bottom: parent.bottom
}
rotationByPinchingEnabled: true
zoomByPinchingEnabled: true
// *** Declare graphics layer***//
GraphicsOverlay {
id: graphicsOverlay
}
}//End Mapview
// Create the intial Viewpoint
ViewpointExtent {
id: viewpoint
extent: Envelope {
xMin: xMinVal
yMin: yMinVal
xMax: xMaxVal
yMax: yMaxVal
spatialReference: SpatialReference { wkid: 4326 }
}
}
Please have the answer
MobileMapPackage {
id: mmpk
path: assetsPath + mapPackageFileName
onLoadStatusChanged: {
if (loadStatus !== Enums.LoadStatusLoaded) {
return;
}
if (mmpk.maps.length < 1) {
return;
}
mapView.map = mmpk.maps[0];
mapView.map.initialViewpoint = viewpoint;
}
onErrorChanged: {
console.log("Mobile Map Package Error: %1 %2".arg(error.message).arg(error.additionalMessage));
}
}