set inital extent for offline map

816
4
Jump to solution
12-11-2020 12:03 AM
rsharma
Occasional Contributor III

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

0 Kudos
1 Solution

Accepted Solutions
rsharma
Occasional Contributor III

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));
            }
     }

View solution in original post

0 Kudos
4 Replies
LukeSmallwood
Esri Contributor

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

0 Kudos
rsharma
Occasional Contributor III

I am using qml with js not cpp. does this fnc work for setting extent setViewpointGeometry

0 Kudos
rsharma
Occasional Contributor III

hi@LukeSmallwood 

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 }
         }
     }

  

0 Kudos
rsharma
Occasional Contributor III

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));
            }
     }
0 Kudos