MapXtreme 操作地图时出现调用目标发生异常的解决方法--地图状态保存
2011-11-21 13:52
387 查看
以下代码位于AppStateManager.cs文件中:
// Restore the state
public override void RestoreState()
{
string mapAlias = ParamsDictionary[ActiveMapAliasKey] as string;
Map map = GetMapObj(mapAlias);
// If it was user's first time and the session was not dirty then save this default state to be applied later.
// If it was a users's first time and the session was dirtythen apply the default state saved in above step to give users ainitial state.
if (IsUsersFirstTime())
{
if (IsDirtyMapXtremeSession(map))
{
RestoreDefaultState(map);
}
else
{
SaveDefaultState(map);
}
}
else
{
// If it is not user's first time then restore the last state they saved
RestoreZoomCenterState(map);
//恢复临时图层Animation的状态
if (HttpContext.Current.Session["Animation" + "Layer"] != null)
{
ManualSerializer.RestoreMapXtremeObjectFromHttpSession("Animation" + "Table");
ManualSerializer.RestoreMapXtremeObjectFromHttpSession("Animation" + "Layer");
}
//恢复标注图层jcbz的状态
if (HttpContext.Current.Session["jcbz" + "Layer"] != null)
ManualSerializer.RestoreMapXtremeObjectFromHttpSession("jcbz" + "Layer");
//恢复临时图层Tm的状态
if (HttpContext.Current.Session["Tm" + "Layer"] != null)
{
ManualSerializer.RestoreMapXtremeObjectFromHttpSession("Tm" + "Table");
ManualSerializer.RestoreMapXtremeObjectFromHttpSession("Tm" + "Layer");
}
// Just by setting it to tempvariables the objects are serialized into session. There is no need toset them explicitly.
for (int i = 0; i < map.Layers.Count ;i++ )
if(map.Layers[i]!=null) //必须加这条语句,否则老是在这里出现错误
ManualSerializer.RestoreMapXtremeObjectFromHttpSession(map.Layers[i].Name+"Layer");
//恢复地图中选中的图元对象
ManualSerializer.RestoreMapXtremeObjectFromHttpSession("Selection");
}
}
// Save the state
public override void SaveState()
{
string mapAlias = ParamsDictionary[ActiveMapAliasKey] as string;
Map map = GetMapObj(mapAlias);
if (map != null)
{
SaveZoomCenterState(map);
//判断地图中是否有Animation图层,有的话保存状态
if (map.Layers["Animation"] != null)
{
ManualSerializer.SaveMapXtremeObjectIntoHttpSession(MapInfo.Engine.Session.Current.Catalog["Animation"],"Animation" + "Table");
ManualSerializer.SaveMapXtremeObjectIntoHttpSession(map.Layers["Animation"], "Animation" + "Layer");
}
//判断地图中是否有Tm图层,有的话保存状态
if (map.Layers["Tm"] != null)
{
ManualSerializer.SaveMapXtremeObjectIntoHttpSession(MapInfo.Engine.Session.Current.Catalog["Tm"],"Tm" + "Table");
ManualSerializer.SaveMapXtremeObjectIntoHttpSession(map.Layers["Tm"], "Tm" + "Layer");
}
//遍历各图层,有层名为jcbz的层则保存该标注图层的状态
for (int i = 0; i < map.Layers.Count; i++)
if (map.Layers[i].Name == "jcbz")
{
ManualSerializer.SaveMapXtremeObjectIntoHttpSession(map.Layers[i], "jcbz" + "Layer");
break;
}
ManualSerializer.SaveMapXtremeObjectIntoHttpSession(map.Layers, "Layers");
ManualSerializer.SaveMapXtremeObjectIntoHttpSession(MapInfo.Engine.Session.Current.Selections.DefaultSelection,"Selection");
}
}
// Restore the state
public override void RestoreState()
{
string mapAlias = ParamsDictionary[ActiveMapAliasKey] as string;
Map map = GetMapObj(mapAlias);
// If it was user's first time and the session was not dirty then save this default state to be applied later.
// If it was a users's first time and the session was dirtythen apply the default state saved in above step to give users ainitial state.
if (IsUsersFirstTime())
{
if (IsDirtyMapXtremeSession(map))
{
RestoreDefaultState(map);
}
else
{
SaveDefaultState(map);
}
}
else
{
// If it is not user's first time then restore the last state they saved
RestoreZoomCenterState(map);
//恢复临时图层Animation的状态
if (HttpContext.Current.Session["Animation" + "Layer"] != null)
{
ManualSerializer.RestoreMapXtremeObjectFromHttpSession("Animation" + "Table");
ManualSerializer.RestoreMapXtremeObjectFromHttpSession("Animation" + "Layer");
}
//恢复标注图层jcbz的状态
if (HttpContext.Current.Session["jcbz" + "Layer"] != null)
ManualSerializer.RestoreMapXtremeObjectFromHttpSession("jcbz" + "Layer");
//恢复临时图层Tm的状态
if (HttpContext.Current.Session["Tm" + "Layer"] != null)
{
ManualSerializer.RestoreMapXtremeObjectFromHttpSession("Tm" + "Table");
ManualSerializer.RestoreMapXtremeObjectFromHttpSession("Tm" + "Layer");
}
// Just by setting it to tempvariables the objects are serialized into session. There is no need toset them explicitly.
for (int i = 0; i < map.Layers.Count ;i++ )
if(map.Layers[i]!=null) //必须加这条语句,否则老是在这里出现错误
ManualSerializer.RestoreMapXtremeObjectFromHttpSession(map.Layers[i].Name+"Layer");
//恢复地图中选中的图元对象
ManualSerializer.RestoreMapXtremeObjectFromHttpSession("Selection");
}
}
// Save the state
public override void SaveState()
{
string mapAlias = ParamsDictionary[ActiveMapAliasKey] as string;
Map map = GetMapObj(mapAlias);
if (map != null)
{
SaveZoomCenterState(map);
//判断地图中是否有Animation图层,有的话保存状态
if (map.Layers["Animation"] != null)
{
ManualSerializer.SaveMapXtremeObjectIntoHttpSession(MapInfo.Engine.Session.Current.Catalog["Animation"],"Animation" + "Table");
ManualSerializer.SaveMapXtremeObjectIntoHttpSession(map.Layers["Animation"], "Animation" + "Layer");
}
//判断地图中是否有Tm图层,有的话保存状态
if (map.Layers["Tm"] != null)
{
ManualSerializer.SaveMapXtremeObjectIntoHttpSession(MapInfo.Engine.Session.Current.Catalog["Tm"],"Tm" + "Table");
ManualSerializer.SaveMapXtremeObjectIntoHttpSession(map.Layers["Tm"], "Tm" + "Layer");
}
//遍历各图层,有层名为jcbz的层则保存该标注图层的状态
for (int i = 0; i < map.Layers.Count; i++)
if (map.Layers[i].Name == "jcbz")
{
ManualSerializer.SaveMapXtremeObjectIntoHttpSession(map.Layers[i], "jcbz" + "Layer");
break;
}
ManualSerializer.SaveMapXtremeObjectIntoHttpSession(map.Layers, "Layers");
ManualSerializer.SaveMapXtremeObjectIntoHttpSession(MapInfo.Engine.Session.Current.Selections.DefaultSelection,"Selection");
}
}
相关文章推荐
- MapXtreme 操作地图时出现调用目标发生异常的解决方法--地图状态保存
- MapXtreme 操作地图时出现调用目标发生异常的解决方法--地图状态保存
- "调用扫描接口出现异常”解决方法
- JNI调用native方法出现 java.lang.UnsatisfiedLinkError: XXXclass.XXXmethod()异常的解决办法
- Dialog调用dismiss方法出现异常解决方法
- IIS下调用证书出现异常的解决方法 (C#)
- VLC的libvlc.dll在release版调用时出现异常解决方法
- Eclipse保存密码时发生异常的解决方法
- SQL2008 新建维护计划 调用的目标发生了异常 从 IClassFactory 为 CLSID 为 {....} 的 COM 组件创建实例失败,原因是出现以下错误:c001f011.(Micros
- JNI调用native方法出现 java.lang.UnsatisfiedLinkError: XXXclass.XXXmethod()异常的解决办法
- Hadoop中操作HDFS出现异常的解决方法
- Visual Studio 2010编译时总是提示"调用目标发生了异常"的解决
- android调用jni方法生成的so库函数的过程&发生的异常解决方法(持续更新)
- Visual Studio 2010编译时总是提示"调用目标发生了异常"的解决
- VS2017 启动调试出现 无法启动程序“http://localhost:15613” 操作在当前状态中是非法的。 同时附加进程也是错误的解决方法
- 快速移动鼠标触发问题及解决方法(ECharts外部调用保存为图片操作及工作流接线mouseenter和mouseleave)
- 解析c#在未出现异常情况下查看当前调用堆栈的解决方法
- c#操作excel时出现COM异常,解决方法
- 解决取消Notification调用cancelALl()方法时出现的空指针异常