Hello!
Could you please clarify a few questions related to the map state management?
As I understand, every time when a user visits a page with a map three items are added to the Session: “<uniquekey>_<mapID>”, “<uniquekey>_<mapID>width” and “<uniquekey>_<mapID>height”. Even if user just refreshes the same page with a map in the browser, a new map unique key is created and stored in the Session in addition to the previous ones. Is this correct? If so, what is the intended way to cleanup old unnecessary map-related items in the Session?
In order to manually manage the map objects in the Session, it would be necessary to know which map objects are created by the given page. But the UniqueControlName property providing the unique key seems to not accessible. So, what is the intended way to get know the unique key of created map?
We are going to use the custom session provider, so, we will need to serialize all Session objects. What is the correct way to serialize the map object?
I tried to get the map object from the session, serialize it with the BinaryFormatter, deserialize it back and replace the session object with the deserialized one. But as result I got the invalid map view.
Can json format be used for the entire map object serialization? There is the FromJson() method , but what is the intended way to build the corresponding json on the server side?
There are overridable SaveState() and LoadState() methods. Can we use them for the serialization? Could you please provide a sample?
With best regards,
Vlad.
Map in session questions
Hi Vlad,
#1,Yes, correct, there will be three session items for a page map every page visit. In order to clear up unnecessary sessions, I am afraid we have to find out the using session items and remove the others with their keys.
#2, You should get the unique key from the client side map, named “pageName” and it is equal to the UniqueControlName in the server side. Try the JS code in client side: Map1.getMapParser().pageName. Actually, in each ajaxCall method, we will pass such key to server side and then server side use it to get the server Map back from session. This is the reason why we can get the map with the MapActionFilter attribution. For example,
[MapActionFilter]
public void ClickEvent(Map map, GeoCollection args)
#3, I am afraid it is hard to serialize the map. This is because some properties in the map instance can’t be serialized, but I think we can serialize the layers as string and deserialize the layer back any time. As for the FromJson method, I have no idea what’s the original propose but as I know we never use it before.
Thanks,
Troy