Select to view content in your preferred language

LocalTileLayer not loading when running through the Player

4253
6
04-18-2016 02:11 PM
G-Palmer
Emerging Contributor


I have created an offline application which uses the ArcGISLocalTileLayer function to display the map. The app loads fully when testing through the Qt Creator but the map doesn't appear when the app's loaded through the Player. Is there anything that I can do to the code to fix this?

0 Kudos
6 Replies
LucasDanzinger
Esri Frequent Contributor

What does your path look like for referencing the local tiled layer?

0 Kudos
G-Palmer
Emerging Contributor

Here's the code for the section that holds the tiled layer components

App {

    id: app

    width: 1220

    height: 880

    property color penColor: colorDialog.color;

    property int penWidth;

    Rectangle {...}

    Map {

        id: map

        anchors {...}

        rotationByPinchingEnabled: true

        zoomByPinchingEnabled: true

      positionDisplay {

            positionSource: PositionSource {

            }

        }

        ArcGISLocalTiledLayer {

            id:aerials

            path: "WairarapaImagery.tpk"

        }

        ArcGISLocalTiledLayer {

            id: vector

            path: "WairarapaVector.tpk"

        }

     ...

    }

0 Kudos
LucasDanzinger
Esri Frequent Contributor

You will need to specify the path to these TPKs. In the case of AppStudio, a good cross platform method is to use is the AppFramework.userHomePath property. This will return to you the "user home" location on each device. In the case of iOS, that would be <application_bundle>/Documents. So, in your code, you could say "path: AppFramework.userHomePath + "/WairarapaImagery.tpk", and then make sure to transfer your TPK to that location on your device (usually via iTunes).

G-Palmer
Emerging Contributor

I tried adding in the userHomePath but the AppStudio player is still not able to display the imagery.

0 Kudos
LucasDanzinger
Esri Frequent Contributor

And the TPK is copied onto the device into that specified location? If not, please use iTunes to transfer the TPK from your desktop onto your device. If you have already done this, then it may be worth posting your question in the AppStudio space. Someone using AppStudio may be able to give you pointers on using the Player app with local offline data.

0 Kudos
nakulmanocha
Esri Regular Contributor

Make sure to create a data folder in your app directory. Add the tpk to the data folder. I have tested this sample code and it works on both android and iPad. Can you please test it by uploading this sample and test it in the player?

import QtQuick 2.3

import QtQuick.Controls 1.2

import ArcGIS.AppFramework 1.0

import ArcGIS.AppFramework.Controls 1.0

import ArcGIS.AppFramework.Runtime 1.0

App {

    id: app

    width: 800

    height: 532

    property string runtimePath: AppFramework.userHomeFolder.filePath("ArcGIS/Runtime")

    property string dataPath: runtimePath + "/Data"

    property string inputTPK: "test.tpk"

    property string outputTPK: dataPath + "/" + inputTPK

    function copyLocalData(input, output) {

        var resourceFolder = AppFramework.fileFolder(app.folder.folder("Data").path);

        AppFramework.userHomeFolder.makePath(dataPath);

        resourceFolder.copyFile(input, output);

        return output

    }

    Envelope {

        id: sfExtent

        xMin: -13643665.582273144

        yMin: 4533030.152110769

        xMax: -13618899.985108782

        yMax: 4554203.2089457335

    }

    Map {

        id: myMap

        anchors.fill: parent

        extent: sfExtent

        focus: true

        ArcGISLocalTiledLayer {

            path: copyLocalData(inputTPK, outputTPK)

        }

    }

}

0 Kudos