Offline Mapping

290
1
11-13-2017 04:49 AM
AneeqaAbrar1
New Contributor III

How can I switch between online and offline map? So my workflow is: the map loads if ocnnected to internet and the tpk loads if internet not connected. 

The code below gives me an online map and it should give me an offline map but its not. Can someone point me in the right direction?


 //Offline Mapping

 property string dataPath: AppFramework.userHomeFolder.filePath("ArcGIS/AppStudio/Data")
 property string inputdata: "Rheinauen.tpk"
 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
 }
 

// Create MapView that contains a Map with the Basemap
    MapView {
        id: mapView
        anchors.top:balken_menu.bottom
        width: parent.width
        height: setInitialMapArea.height - balken_menu.height
        focus: true
        rotationByPinchingEnabled: false
        zoomByPinchingEnabled: true
        Map {
            id: map
            minScale: 100000
            maxScale: 5000
            BasemapTopographic {}
            // Add a tiled layer as an operational layer
            ArcGISTiledLayer {
                id: tiledLayer
                url: "https://tiles.arcgis.com/tiles/1tklMVd2WsYssnvp/arcgis/rest/services/Labels/MapServer"
            }
            initialViewpoint: viewpoint
//            Basemap {
                ArcGISTiledLayer {
                    TileCache {
                        id: offlinemap
                        path: AppFramework.resolvedPathUrl(copyLocalData(inputdata, outputdata))
                    }
                }
        }
0 Kudos
1 Reply
JaysonWard
New Contributor III

I can't be certain, but I have a feeling this may have to do with the path value being set on the TileCache object. My suggestion would be to console log that path property out and make sure it is a valid path being set.

0 Kudos