整理AE开发之地图加载.docx

上传人:b****3 文档编号:10819048 上传时间:2023-05-27 格式:DOCX 页数:25 大小:20.30KB
下载 相关 举报
整理AE开发之地图加载.docx_第1页
第1页 / 共25页
整理AE开发之地图加载.docx_第2页
第2页 / 共25页
整理AE开发之地图加载.docx_第3页
第3页 / 共25页
整理AE开发之地图加载.docx_第4页
第4页 / 共25页
整理AE开发之地图加载.docx_第5页
第5页 / 共25页
整理AE开发之地图加载.docx_第6页
第6页 / 共25页
整理AE开发之地图加载.docx_第7页
第7页 / 共25页
整理AE开发之地图加载.docx_第8页
第8页 / 共25页
整理AE开发之地图加载.docx_第9页
第9页 / 共25页
整理AE开发之地图加载.docx_第10页
第10页 / 共25页
整理AE开发之地图加载.docx_第11页
第11页 / 共25页
整理AE开发之地图加载.docx_第12页
第12页 / 共25页
整理AE开发之地图加载.docx_第13页
第13页 / 共25页
整理AE开发之地图加载.docx_第14页
第14页 / 共25页
整理AE开发之地图加载.docx_第15页
第15页 / 共25页
整理AE开发之地图加载.docx_第16页
第16页 / 共25页
整理AE开发之地图加载.docx_第17页
第17页 / 共25页
整理AE开发之地图加载.docx_第18页
第18页 / 共25页
整理AE开发之地图加载.docx_第19页
第19页 / 共25页
整理AE开发之地图加载.docx_第20页
第20页 / 共25页
亲,该文档总共25页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

整理AE开发之地图加载.docx

《整理AE开发之地图加载.docx》由会员分享,可在线阅读,更多相关《整理AE开发之地图加载.docx(25页珍藏版)》请在冰点文库上搜索。

整理AE开发之地图加载.docx

整理AE开发之地图加载

usingSystem;

usingSystem.Collections.Generic;

usingSystem.Linq;

usingSystem.Text;

usingESRI.ArcGIS.AnalysisTools;

usingESRI.ArcGIS.Analyst3D;

usingESRI.ArcGIS.Carto;

usingESRI.ArcGIS.Controls;

usingESRI.ArcGIS.Display;

usingESRI.ArcGIS.DisplayUI;

usingESRI.ArcGIS.esriSystem;

usingESRI.ArcGIS.Geodatabase;

usingESRI.ArcGIS.Geometry;

usingESRI.ArcGIS.GlobeCore;

usingESRI.ArcGIS.Output;

usingESRI.ArcGIS.SystemUI;

usingESRI.ArcGIS.DataSourcesRaster;

usingESRI.ArcGIS.DataSourcesRasterUI;

usingSystem.Windows.Forms;

usingSystem.Drawing;

usingESRI.ArcGIS.DataSourcesFile;

namespaceAEExercise

{

publicclassGeoMapLoad

{

publicstaticIMapDocumentpMapDocument;//定义地图文档接口变量

publicstaticintcount=0;

publicstaticIRgbColorpColor;//设置颜色

publicstaticstringtext="空";//标注内容

publicstaticvoidCreateMeasuredGrid(AxPageLayoutControlaxPageLayoutControl1)

{

//设置格网点

ISnapGridpSnapGrid;

IPageLayoutpPageLayout=axPageLayoutControl1.PageLayout;

pSnapGrid=pPageLayout.SnapGrid;//获取PageLayout的SnapGrid对象

pSnapGrid.VerticalSpacing=2;//设置垂直间距

pSnapGrid.HorizontalSpacing=1;

pSnapGrid.IsVisible=true;//设置为可见

axPageLayoutControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics,null,null);

}

publicstaticvoidoperatePageLayout(AxPageLayoutControlaxPageLayoutControl1,stringopt,IEnvelopepEnv,intstrBarType=0)

{

switch(opt)

{

case"AddScale":

{

if(count>0)

return;

IScaleBarpScaleBar;

IMapFramepMapFrame;

IMapSurroundFramepMapSurroundFrame;

IMapSurroundpMapSurround;

IElementPropertiespElementPro;

//产生一个UID对象,使用它产生不同的MapSurround对象􁇍􄈵

UIDpUID=newUIDClass();

pUID.Value="esriCarto.scalebar";

IPageLayoutpPageLayout;

pPageLayout=axPageLayoutControl1.PageLayout;

IGraphicsContainerpGraphicsContainer;

pGraphicsContainer=pPageLayoutasIGraphicsContainer;

IActiveViewpActiveView;

pActiveView=pGraphicsContainerasIActiveView;

IMappMap;

pMap=pActiveView.FocusMap;

//获得于地图相关的MapFrame

pMapFrame=pGraphicsContainer.FindFrame(pMap)asIMapFrame;

//产生MapsurroundFrame

pMapSurroundFrame=pMapFrame.CreateSurroundFrame(pUID,null);

//依据传入参数不同使用不同类型的比例尺

MessageBox.Show(strBarType.ToString());

switch(strBarType)

{

case0:

//西安交互比例尺pScaleBar=newAlternatingScaleBarClass();

break;

case1:

//双线交互比例尺

pScaleBar=newDoubleAlternatingScaleBarClass();

break;

case2:

//中空式比例尺

pScaleBar=newHollowScaleBarClass();

break;

case3:

//线式比例尺

pScaleBar=newScaleLineClass();

break;

case4:

//分割式比例尺

pScaleBar=newSingleDivisionScaleBarClass();

break;

case5:

//阶梯式比例尺

pScaleBar=newSteppedScaleLineClass();

break;

default:

pScaleBar=newScaleLineClass();

break;

}

pScaleBar.Division=4;

pScaleBar.Divisions=4;

pScaleBar.LabelGap=4;

pScaleBar.LabelPosition=esriVertPosEnum.esriAbove;

pScaleBar.Map=pMap;

pScaleBar.Name="比例尺";

pScaleBar.Subdivisions=2;

pScaleBar.UnitLabel="千米";

pScaleBar.UnitLabelGap=4;

pScaleBar.UnitLabelPosition=esriScaleBarPos.esriScaleBarAbove;

pScaleBar.Units=esriUnits.esriKilometers;

pMapSurround=pScaleBar;

pMapSurroundFrame.MapSurround=pMapSurround;

pElementPro=pMapSurroundFrameasIElementProperties;

pElementPro.Name="myscalebar";

//将MapSurrooundFrame对象添加到控件中axPageLayoutControl1.AddElement(pMapSurroundFrameasIElement,

pEnv,Type.Missing,Type.Missing,0);

pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics,null,null);

break;

}

}

}

publicvoidOperateMapDoc(AxMapControlaxMapControl1,AxMapControlaxMapControl2,stringstrOperateType)

{

//定义打开文件对话框

OpenFileDialogOpenFileDlg=newOpenFileDialog();

//定义保存文件对话框

SaveFileDialogSaveFileDlg=newSaveFileDialog();

OpenFileDlg.Filter="地图文档文件(*.mxd)|*.mxd";

SaveFileDlg.Filter="地图文档文件(*.mxd)|*.mxd";

stringstrDocFileN=string.Empty;

pMapDocument=newMapDocumentClass();

//判断操作文档地图的类型

switch(strOperateType)

{

case"NewDoc":

{

SaveFileDlg.Title="输入需要新建地图文档的名称";

SaveFileDlg.ShowDialog();

strDocFileN=SaveFileDlg.FileName;

if(strDocFileN==string.Empty)

return;

pMapDocument.New(strDocFileN);

pMapDocument.Open(strDocFileN,"");

axMapControl1.Map=pMapDocument.get_Map(0);

break;

}

case"OpenDoc":

{

OpenFileDlg.Title="选择需要加载的地图文档文件";

OpenFileDlg.ShowDialog();

strDocFileN=OpenFileDlg.FileName;

if(strDocFileN==string.Empty)

return;

//将数据加载入pMapDocument并与map控件联动起来

pMapDocument.Open(strDocFileN,"");

for(inti=0;i

{

//遍历可能的Map对象

axMapControl1.Map=pMapDocument.get_Map(i);

//axMapControl2.Map=pMapDocument.get_Map(i);

}

//刷新地图

axMapControl1.Refresh();

break;

}

case"SaveDoc":

{

//判断文档是否为只读文档

if(pMapDocument.get_IsReadOnly(pMapDocument.DocumentFilename)==true)

{

MessageBox.Show("此地图文档为只读文档!

","信息提示");

return;

}

//用相对路径保存地图文档

pMapDocument.Save(pMapDocument.UsesRelativePaths,true);

MessageBox.Show("保存成功!

","信息提示");

break;

}

case"SaveDocAs":

{

SaveFileDlg.Title="地图文档另存";

SaveFileDlg.ShowDialog();

strDocFileN=SaveFileDlg.FileName;

if(strDocFileN==string.Empty)

return;

if(strDocFileN==pMapDocument.DocumentFilename)

{

//将修改后的地图文档保存在原文件中

//用相对路径保存地图文档

pMapDocument.Save(pMapDocument.UsesRelativePaths,true);

MessageBox.Show("保存成功!

","信息提示");

break;

}

else

{

//将修改后的地图文档保存为新文件

pMapDocument.SaveAs(strDocFileN,true,true);

MessageBox.Show("保存成功!

","信息提示");

}

break;

}

default:

break;

}

}

publicvoidSetColor()

{

pColor=getRGBColor();

}

publicvoidMapOperate(AxMapControlaxMapControl1,IMapControlEvents2_OnMouseDownEvente,stringstrOperat)

{

if(pColor==null)

{

pColor=newRgbColorClass();

pColor.Blue=5;

pColor.Red=213;

pColor.Green=9;

}

switch(strOperat)

{

case"strLKoper":

{

axMapControl1.MousePointer=esriControlsMousePointer.esriPointerCrosshair;

axMapControl1.Extent=axMapControl1.TrackRectangle();

axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography,null,null);

break;

}

case"strMapPan":

{

axMapControl1.Pan();

break;

}

//绘制线

case"strDrawLine":

{

//绘制线

IMappMap;

IActiveViewpActiveView;

pMap=axMapControl1.Map;

pActiveView=pMapasIActiveView;

IPolylinepPolyline;

pPolyline=axMapControl1.TrackLine()asIPolyline;

//产生一个SimpleLineSymbol符号

ISimpleLineSymbolpSimpleLineSym;

pSimpleLineSym=newSimpleLineSymbolClass();

pSimpleLineSym.Style=esriSimpleLineStyle.esriSLSSolid;//需要用户动态选择

//设置符号颜色

pSimpleLineSym.Color=pColor;//需要用户动态选择

pSimpleLineSym.Width=1;

//产生一个PolylineElement对象

ILineElementpLineEle;

pLineEle=newLineElementClass();

IElementpEle;

pEle=pLineEleasIElement;

pEle.Geometry=pPolyline;

try

{//将元素添加到Map对象之中

IGraphicsContainerpGraphicsContainer;

pGraphicsContainer=pMapasIGraphicsContainer;

pGraphicsContainer.AddElement(pEle,0);

pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics,null,null);

}

catch(ExecutionEngineExceptione3)

{

MessageBox.Show("两点距离太近");

return;

}

break;

}

//绘制面

case"strDrawPolygon":

{

//绘制面

IMappMap;

IActiveViewpActiveView;

pMap=axMapControl1.Map;

pActiveView=pMapasIActiveView;

IPolygonpPolygion;

pPolygion=axMapControl1.TrackPolygon()asIPolygon;

//产生一个SimpleFillSymbol符号

ISimpleFillSymbolpSimpleFillSym;

pSimpleFillSym=newSimpleFillSymbolClass();

pSimpleFillSym.Style=esriSimpleFillStyle.esriSFSDiagonalCross;//需要用户动态选择

pSimpleFillSym.Color=pColor;//需要用户动态选择

//产生一个PolygonElement对象

IFillShapeElementpPolygonEle;

pPolygonEle=newPolygonElementClass();

pPolygonEle.Symbol=pSimpleFillSym;

IElementpEle;

pEle=pPolygonEleasIElement;

pEle.Geometry=pPolygion;

//将元素添加到Map对象之中

IGraphicsContainerpGraphicsContainer;

pGraphicsContainer=pMapasIGraphicsContainer;

pGraphicsContainer.AddElement(pEle,0);

pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics,null,null);

break;

}

//地图标注

case"strMapLable":

{

//地图标注

IMappMap;

IActiveViewpActiveView;

pMap=axMapControl1.Map;

pActiveView=pMapasIActiveView;

ITextElementpTextEle;

IElementpEles;

//建立文字符号对象,并设置相应的属性

pTextEle=newTextElementClass();

pTextEle.Text=text;

pEles=pTextEleasIElement;

//设置文字字符的几何形体属性

IPointpPoint;

pPoint=newPointClass();

pPoint.PutCoords(e.mapX,e.mapY);

pEles.Geometry=pPoint;

//添加到Map对象中,并刷新显示

IGraphicsContainerpGraphicsContainer;

pGraphicsContainer=pMapasIGraphicsContainer;

pGraphicsContainer.AddElement(pEles,0);

pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics,null,null);

break;

}

case"strSelect":

{

//要素选择

//得到一个包络线Envelope对象

IEnvelopepEnv;

pEnv=axMapControl1.TrackRectangle();

//新建选择集环境对象

ISelectionEnvironmentpSelectionEnv;

pSelectionEnv=newSelectionEnvironmentClass();

//改变选择集的默认颜色

pSelectionEnv.DefaultColor=pColor;

//选择要素,并将其放入选择集

axMapControl1.Map.SelectByShape(pEnv,pSelectionEnv,false);

axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection,null,null);

//需要遍历所选要素

break;

}

case"LKselect":

{

IMappMap;

IActiveViewpActiveView;

pMap=axMapControl1.Map;

pActiveView=pMapasIActiveView;

IEnvelopepEnv;

pEnv=axMapControl1.TrackRectangle();

ISelectionEnvironmentpSelct;

pSelct=newSelectionEnvironmentClass();

pSelct.DefaultColor=pColor;

pMap.SelectByShape(pEnv,pSelct,false);

pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection,null,null);

break;

}

case"PointSelect":

{

IMappMap;

IActiveViewpActiveView;

pMap=axMapControl1.Map;

pActiveView=pMapasIActiveView;

IP

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工作范文 > 行政公文

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2