AnsweredAssumed Answered

Unable to create simple app for viewing MMP with location

Question asked by MervynLotter on Dec 17, 2017
Latest reply on Dec 23, 2017 by MervynLotter

Hi there


I am hoping somebody can advise me where I have gone wrong. I have created a rather simple app using the "Open Mobile Map" template to which I have added functionality to view the device's location on the MMPK. This app opens and views correctly when I run app from within AppStudio (Shift+Alt+r) but not when I download app onto mobile device, either as a built app or to view via AppStudio Player 2.1.23 on a Samsung S8+ phone. When I try from AppStudio Player then all I see is the location button but not the MMPK. The MMPK is being placed in the C:\Users\xxxxx\ArcGIS\AppStudio\Data folder before uploading and/or building app.


I paste the code I used below:

import QtQuick 2.7
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.1
import QtQuick.Controls.Material 2.1
import ArcGIS.AppFramework 1.0
import ArcGIS.AppFramework.Controls 1.0
import Esri.ArcGISRuntime 100.1
import QtPositioning 5.8
import QtSensors 5.2
import "controls" as Controls
App {
    id: app
    width: 414
    height: 736
    function units(value) {
        return AppFramework.displayScaleFactor * value
    property real scaleFactor: AppFramework.displayScaleFactor
    property int baseFontSize :"baseFontSize", 15 * scaleFactor) + (isSmallScreen ? 0 : 3)
    property bool isSmallScreen: (width || height) < units(400)
    property string dataPath:  AppFramework.userHomeFolder.filePath("ArcGIS/AppStudio/Data")
    property string inputdata: "KrugerNP2.mmpk"
    property string outputdata: dataPath + "/" + inputdata
    function copyLocalData(input, output) {
        var resourceFolder = AppFramework.fileFolder(app.folder.folder("data").path);
        resourceFolder.copyFile(input, output);
        return output
        anchors.fill: parent
        header: ToolBar{
            width: parent.width
            height: 50 * scaleFactor
            Material.background: "green"
        // sample starts here ------------------------------------------------------------------
        contentItem: Rectangle{
            // Create MapView
            MapView {
                id: mapView
                anchors.fill: parent
                                    right: parent.right
                                    rightMargin: 16 * scaleFactor
                                    verticalCenter: parent.verticalCenter
                                                    imageSource: "./assets/location.png"
                                                       onIconClicked: {
                                                          if (!mapView.locationDisplay.started) {
                                                              mapView.locationDisplay.autoPanMode = Enums.LocationDisplayAutoPanModeRecenter
                                                              colorOverlay.color = "steelblue"
                                                          }else {
                                                              colorOverlay.color = "#4c4c4c"
                locationDisplay {
                                positionSource: PositionSource {
            // Create a Mobile Map Package and set the path
            MobileMapPackage {
                id: mmpk
                path: AppFramework.resolvedPathUrl(copyLocalData(inputdata, outputdata))
                // load the mobile map package
                Component.onCompleted: {
                // wait for the mobile map package to load
                onLoadStatusChanged: {
                    if (loadStatus === Enums.LoadStatusLoaded) {
                        // set the map view's map to the first map in the mobile map package
               = mmpk.maps[0];
            //! [open mobile map package qml api snippet]
    // sample ends here ------------------------------------------------------------------------
        visible: false