Change TPK loaded

309
4
09-09-2019 09:22 AM
jaykapalczynski
Frequent Contributor

Can you change the TPK that was initially loaded in your app

// SNIP

Item {
    id: mmpkManager 

    property string itemName2: "backgrounddatatpk.tpk"
    property string filePath: [fileFolder2.path, itemName2].join("/")


    property string itemName3: "backgrounddatatpk.tpk"
    property url fileUrl3: [fileFolder3.url, itemName3].join("/")



    // THIS IS FOR THE PATHING TO THE TOPOS ASKED FOR IN THE LoadService.qml
    FileFolder {
        id: fileFolder2

        //USE THIS WHEN USING PLAYER ON THE DESKTOP
        //property string exLocation:AppFramework.userHomeFolder.filePath("ArcGIS/AppStudio/Data/QuickReport")

        path: exLocation
        Component.onCompleted: {

            console.log("exLocation: " + exLocation)
        }
    }


    FileFolder {
        id: fileFolder3

        //USE THIS WHEN USING PLAYER ON THE DESKTOP
        property string exLocation:AppFramework.userHomeFolder.filePath("ArcGIS/AppStudio/Data/QuickReport")

        url: exLocation3
        Component.onCompleted: {

            console.log("exLocation 3 : " + exLocation3)
        }
    }

}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

   //SNIP

    property string dataPath:  app.mmpkManager.filePath

    property string dataURL3:  app.mmpkManager.fileUrl3

        MapView{
            id: mapView

            Map{
                id: map

                Basemap {
                    ArcGISTiledLayer {
                       url: dataPath
                    }
                }
      // SNIP






Button {
     id: offlineSwitchButton
     visible: true
     text: "change basemap"

    var location = JSON.stringify({url: dataURL3});

    onClicked: {
         var mapping = ArcGISRuntimeEnvironment.createObject("Basemap", location);
         mapView.map = mapping;
    }
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
4 Replies
jaykapalczynski
Frequent Contributor

I have been trying this to change the URL or PATH and cant get working...

Can I change the tpk file in an app with drop down or a button.  I know I can do this with mmpk files...

Creating a new object for TileCache

This is what I get in the console when trying to SET the TileCache OBECJT and then trying to set the NewMAP

:

Esri.ArcGISRuntime.Core: class QmlImageProvider *__cdecl QmlImageSource::imageProvider(class QObject *) No context for: QmlTileCacheThumbnail

qml: {"objectName":"mapTileCache","objectType":"TileCache","error":null,"objects":{},"loadError":null,"loadStatus":3,"path":"file:///Android/data/com.dgif.background.data/QuickReport/backgrounddatatpk.tpk","thumbnailUrl":"image://arcgisruntimeimageprovider/046a7700-d612-4c29-a59c-011fe175a4bf/thumbnail","tileInfo":null,"antialiasing":false,"cacheStorageFormat":-1,"fullExtent":null}

ArcGIS.AppFramework.Player: Object: QObject(0x0) Text: "file:///C:/Users/tjv36463/ArcGIS/AppStudio/Apps/03d396a4adaf4087837688ceb176474b/QuickReport/pages/NavigateOffline.qml:2949: Error: Cannot assign QObject* to QUrl"

file:///C:/Users/tjv36463/ArcGIS/AppStudio/Apps/03d396a4adaf4087837688ceb176474b/QuickReport/pages/NavigateOffline.qml:2949: Error: Cannot assign QObject* to QUrl

// modifiedPath equals "file:///Android/data/com.dgif.background.data/QuickReport/backgrounddatatpk.tpk";
var webmapUrl = modifiedPath

var newMap = ArcGISRuntimeEnvironment.createObject("TileCache", {path: webmapUrl,objectName: "mapTileCache"});

// Set the map to the MapView
console.log(JSON.stringify(newMap));


mapTileCache.path = newMap
0 Kudos
jaykapalczynski
Frequent Contributor

anyone have any ideas on this?

0 Kudos
jaykapalczynski
Frequent Contributor

can I change a loaded TPK file?  Is it possible?  I know I can change a MMPK file or mobile map....can I do this with a TPK file?????

0 Kudos
jaykapalczynski
Frequent Contributor

Anyone have any ideas on this?  Can I change an already loaded TPK with another one.

0 Kudos