ThinkGeo.com    |     Documentation    |     Premium Support

Map Suite SaveState and LoadState

Hi @Ethan
I use a map control to load a shape map file, I use the map control method SaveState and LoadState.
code:


private byte[] mapState;
private void save_Click(object sender, RoutedEventArgs e)
{
mapState = MapControl.SaveState();
}

    private void load_Click(object sender, RoutedEventArgs e)
    {
        if(mapState != null)
        {
              MapControl.LoadState(mapState);
        }
    }

 The saved state can be successful, but there is an empty reference error when loading.

regards,
ZhangMing.

Hi ZhangMing,

I think the API SaveState and SaveState should have some problem, our developer will look into it.

Please try this workaround for now:

byte[] mapState;

    private void button_Click(object sender, RoutedEventArgs e)
    {
        GeoSerializer serializer = new GeoSerializer();

        MemoryStream stream = new MemoryStream();
        serializer.Serialize(map, stream);            
        mapState = stream.ToArray();
    }

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        GeoSerializer serializer = new GeoSerializer();

        MemoryStream stream = new MemoryStream(mapState);            

        WpfMap map = serializer.Deserialize(stream) as WpfMap;            
    }

Regards,

Ethan

Hi @Ethan
thanks. i will try.
Regards,
ZhangMing

Hi ZhangMing,

Any question please let us know.

Regards,

Ethan