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
//GPS
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 : app.info.propertyValue("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);
AppFramework.userHomeFolder.makePath(dataPath);
resourceFolder.copyFile(input, output);
return output
}
Page{
anchors.fill: parent
header: ToolBar{
id:header
width: parent.width
height: 50 * scaleFactor
Material.background: "green"
Controls.HeaderBar{}
}
// sample starts here ------------------------------------------------------------------
contentItem: Rectangle{
anchors.top:header.bottom
// Create MapView
MapView {
id: mapView
anchors.fill: parent
ColumnLayout{
anchors{
right: parent.right
rightMargin: 16 * scaleFactor
verticalCenter: parent.verticalCenter
}
Controls.FloatActionButton{
id:locationButton
imageSource: "./assets/location.png"
onIconClicked: {
if (!mapView.locationDisplay.started) {
mapView.locationDisplay.start()
mapView.locationDisplay.autoPanMode = Enums.LocationDisplayAutoPanModeRecenter
colorOverlay.color = "steelblue"
}else {
mapView.locationDisplay.stop()
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: {
mmpk.load();
}
// 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
mapView.map = mmpk.maps[0];
}
}
}
//! [open mobile map package qml api snippet]
}
}
// sample ends here ------------------------------------------------------------------------
Controls.DescriptionPage{
id:descPage
visible: false
}
}