Select to view content in your preferred language

Save and Load Map

460
3
03-18-2022 05:40 AM
Lazyman
New Contributor II

Hi, I'm new to runtime SDK WPF. I don't know how to Save Map with several layers on local file and Load Map next time, just like mxd or arpx file. Can you help me, please?

0 Kudos
3 Replies
JoeHershman
MVP Regular Contributor

A little more information about what you want to accomplish by saving the map might be helpful.  A map is simply a collection of layers and the configuration of those layers.  There is a Map.ToJson method which allows you to write out the definition of the Map in Json and there is a FromJson method that could rehydrate a map object with that same definition.

I think that is probably what you would want if you are trying to save a Map object definition.

Thanks,
-Joe
0 Kudos
Lazyman
New Contributor II

I start my wpf app, load some local data layers, then "save the map". When I start my app next time, I can load the map with layers and everything saved last time. I've tried Map.ToJson(), it seams only save the basic map infomation, but no local data layers. Do I have to write a custom project file by myself? I'm not sure if arcgis runtime sdk support loading map directly from arcgis pro file (*.arpx), and save changes back.

arcgispro.png

0 Kudos
JoeHershman
MVP Regular Contributor

I had never really looked at the ToJson() output I had just assumed it would have everything, but I see that I was the wrong in that assumption.

I think the best way to do something along those lines would be to look at a mobile map package and mimic that in saving the map.  The mobile map package is basically just a folder that contains everything that is in the offline map.  One of the things in there is a mobile_map.mmap file which contains the json defining the entire map including layers (this is what I had assumed the ToJson output was).

I am still not clear how you are initially loading a map and why that approach is not available the second time you want to load a map, as opposed to this idea of saving it.  In any workflow I have used either I am using an offline map package, have all the data stored offline in a known structure, or am using an online map.

I am still not really understanding why you need a separate mechanism to save/open the map vs. just using the code that originally loaded the map

 

Thanks,
-Joe
0 Kudos