MapXtreme 操作地图时出现调用目标发生异常的解决方法--地图状态保存
2010-05-26 14:19
525 查看
以下代码位于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 操作地图时出现调用目标发生异常的解决方法--地图状态保存
- POI操作excel2007 出现异常 java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlOptions 解决方法
- JNI调用native方法出现 java.lang.UnsatisfiedLinkError: XXXclass.XXXmethod()异常的解决办法
- asp.net出现的异常:"由于代码已经过优化或者本机框架位于调用堆栈之上,无法计算表达式的值" 的解决方法
- VLC的libvlc.dll在release版调用时出现异常解决方法
- Silverlight 动态调用XAP 发生异常解决方法
- 快速移动鼠标触发问题及解决方法(ECharts外部调用保存为图片操作及工作流接线mouseenter和mouseleave)
- 调用远程数据库的存储过程出现“ORA-02064不支持分布式操作”错误的解决方法
- JNI调用native方法出现 java.lang.UnsatisfiedLinkError: XXXclass.XXXmethod()异常的解决办法
- Visual Studio 2010编译时总是提示"调用目标发生了异常"的解决
- android调用jni方法生成的so库函数的过程&发生的异常解决方法(持续更新)
- 子线程中调用UpdateData(TRUE/FALSE)出现异常解决方法
- 解决调用context.Session["NAME"]时总出现Object reference not set to an instance of an object.异常的方法
- 在使用EF时调用DBFUNCTION扩展方法时,发生ENTITYCOMMANDEXECUTIONEXCEPTION 异常的解决办法
- WebService调用时创建应用程序事件日志时出现异常的解决方法
- VS2010 F5调试时出现:“ 尝试运行项目时出错:未捕获通过反射调用的方法引发的异常”解决
- c#操作excel时出现COM异常,解决方法
- JNI调用native方法出现 java.lang.UnsatisfiedLinkError: XXXclass.XXXmethod()异常的解决办法