ArcGIS Runtime SDK for .NET (Windows Phone) - ArcGISLocalTiledLayer Issue

3408
6
07-30-2015 04:23 AM
AndrejMelicher
New Contributor II

I'm developing Windows Phone 8.1 client for our company ArcGIS maps. Online layers works fine, but I need to deliver offline maps (Map Tile Package - .tpk file) to users with bad connectivity. My problem is that not every user has device with Storage Card, and I try to save .tpk file to Internal Storage of Phone, i.e. Pictures Library folder.

I can succesfully read .tpk file from there to StorageFile, so the app has the permission to read, but I cannot initialize ArcGISLocalTiledLayer from this file. Even when I copy file to App Local Store, still cannot initialize ArcGISLocalTiledLayer from this file. I tried different path formats:

// Settings.LocalDataPath = "C:\\Data\\Users\\Public\\Pictures\\Camera Roll\\ArcGIS\\MS_PM_BaseMap.tpk"; - when loading from Pictures Library 
// Settings.LocalDataPath = "ms-appdata:///local/MS_PM_BaseMap.tpk"; - when file is in Local Storage 
// Settings.LocalDataPath = "isostore:/MS_PM_BaseMap.tpk"; - another try...  

var tpk = new ArcGISLocalTiledLayer(Settings.LocalDataPath); 
tpk.ID = "tpk"; 
await tpk.InitializeAsync();

on InitializeAsync() I get exception "Failed to open file. May not be a valid tile package.". When file is saved on StorageCard, initialization works fine. Is it possible to use .tpk file from any location in phone's internal storage?

0 Kudos
6 Replies
AnttiKajanus1
Regular Contributor II

Have you checked our samples using local data in Windows Phone? ie. arcgis-runtime-samples-dotnet/ArcGISLocalTiledLayerSample.xaml.cs at master · Esri/arcgis-runtime-sa... 

In samples app we just download set of data into the application data folders and use it from there. Let me know if you still have issues with this and if it seems that the tpk cannot be initialized from some reason, could you send it to me for testing?

cheers,

Antti

0 Kudos
AndrejMelicher
New Contributor II

Thanks for answer. I did not catch the option to use StorageFile as constructor attribute in documentation, good point. I tried it this way, but still no success when loading file from Pictures Library. Got the same exception when using like this:

StorageFolder folder = (await KnownFolders.PicturesLibrary.GetFoldersAsync())[0]; 
StorageFile file = await gisFolder.GetFileAsync(name + ".tpk"); 
var tpk = new ArcGISLocalTiledLayer(file); 
await tpk.InitializeAsync(); 


I can copy file to application data folder and read it from there, but this is not really what I want. Our users needs the option to switch different map files and store each of them in application data folder is tricky...

0 Kudos
AnttiKajanus1
Regular Contributor II

I'm not sure if the PicturesLibary is a good place to store mapping data. We know that we have some limitations to using offline files in different locations in the phone and I would guess that we haven't tested this scenario before.

Could you define the workflow that you have been thinking for managing the data in the WindowsPhone? How the data is delivered into the device, how it's used and managed in the application?

From platform point of view, using ArcGIS Portal or ArcGIS Online as a data hub works very well to deliver data dynamically to your applications, provides easy way to distribute updates and help to unlock Standard licensing (you can take the application offline for 30 days by signing into the portal/online and saving the token to the device - no need for separate deployment license).

I drew a simple chart of this that might clarify it this a bit. Basically you can deliver any data to the your applications this way and you can implement some data being automatically downloaded, some on request basis and you can control who has access to what data. Data can be uploaded to the portal manually or you can automatize it if needed so process vice you have a lot of options.

WP_20150731_004.jpg

I talked this approach in DevSummit this year and you can find recording from here ArcGIS Runtime SDK for .NET: Transitioning to It from Other Esri .NET SDKs | Esri Video and sharing data section starts around 24:50. Code can be downloaded from http://www.arcgis.com/home/item.html?id=865907613bdd4f1bae1f0537f5a48d84 

0 Kudos
AndrejMelicher
New Contributor II

Hi, sorry for delay, I was offline during weekend.

In WP, you don't have many options where to store custom data when your device don't support SD card. The Documents folder is inaccesible for 3rd party apps, then you have Pictures, Music and Video Library... Nothing else.

In my scenario, end users are foresters with very limited connectivity on phones, and little better connectivity on their PCs in offices. So the best option for them is to copy files from PCs to phones via USB cable, and as I wrote before, there are different map packages then need to have on devices and switch them on demand.

In conclusion, I'm going to use "copy to application data storage" scenario, but maybe in future, it would be nice if ArcGIS SDK supports locations like Pictures Library to store .tpk files.

0 Kudos
AndrejMelicher
New Contributor II

Hi, another complication, don't know if need to create a new thread, maybe placing the question here would be fine.

As I wrote before, I successfully use TPK file stored in SD card when testing release build locally. But now I publish the package to Store and again I get exception "Failed to open file. May not be a valid tile package." even when TPK file is located on SD card. Some kind of strange security issue when package is published on Store?

0 Kudos
dotMorten_esri
Esri Frequent Contributor

There's only two valid root locations for TPK files to be readable in a phone app: Local and App data. Ie ms-appdata:///... and ms-appx:///...

That you can read a file using the StorageFile APIs unfortunately doesn't confirm whether it's usable, as we require direct native read of the file to be able to use them at this point. We are aware this isn't ideal, but it's unfortunately a platform limitation at this point. I would however encourage you to vote for this issue to improve this in the future:

https://wpdev.uservoice.com/forums/253374-missing-platform-apis/suggestions/6039773-improve-storagef...