AnsweredAssumed Answered

How to display a local basemap (.vtpk) with a Mobile Map Package

Question asked by TCVanHalen on Sep 21, 2020
Latest reply on Sep 25, 2020 by mbockenhauer-esristaff

Whatever I try I cannot get a basemap to show with a Mobile Map Package.  I would rather show a local vtpk instead of an esri online basemap.  Here is my code:

 

Item {
    anchors.fill: parent
    signal openMenu()
    property string searchPane: ""
    property string inputdata: "ZooScapeMKE.mmpk"
    property string locatorFileName: "Locator-MKE.loc"
    property string filePath: "../data/"
    MapView {
        id: mapView
        anchors.fill: parent
        focus: true
    }
    MobileMapPackage {
        id: mmpk
        path: filePath + inputdata
        Component.onCompleted: {
            mmpk.load();
        }
        onLoadStatusChanged: {
            if (loadStatus === Enums.LoadStatusLoaded) {
                mapView.map = mmpk.maps[0];
                console.log(mapView.map.spatialReference.wkid);
                mapView.map.minScale = 15000;
                mapView.map.maxScale = 1000;
                var basemapLayer = ArcGISRuntimeEnvironment.createObject("ArcGISVectorTiledLayer", {url: filePath + "BasemapGrayMKE.vtpk"});
                mapView.map.basemap.baseLayers.append(basemapLayer);
            }
        }
    }
}

Outcomes