




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、地图文档管理pagelayout地图管理图层管理render一、 地图文档管理lxmxddocument class接口imapdocment imapcontrol3 ipagelayoutcontrol2功能:新建、打开、保存、另存、设置保存路径(相对还是绝对路径)、新建public bool createmapdocument(string mxdpath)方法功能:新建地图文档输入参数:string mxdpath 地图文档的保存路径返回参数:bool 值为true时,表示新建成功;值为false表示建立失败打开public bool openmap(string strpath,bo
2、ol bpagelayout)方法功能:在mapcontrol或pagelayout中打开给定的图文件输入参数:string strmxdpath 打开的地图文档路径及文件名 bool bpagelayout 是否用pagelayout打开地图返回参数: bool 值为true时,表示打开成功;值为false表示打开失败保存public bool savemapdocument(string psmxdfile,string ptmxdfile)方法功能 保存mxd文件输入参数 string psmxdfile 源mxd文件名string ptmxdfile 目标mxd文件名注意psmxdfi
3、le与ptmxdfile相等返回参数:bool 值为true时,表示保存成功;值为false表示保存失败另存public bool saveasmapdocument(string psmxdfile,string ptmxdfile)方法功能 保存mxd文件输入参数 string psmxdfile 源mxd文件名string ptmxdfile 目标mxd文件名注意psmxdfile与ptmxdfile不相等返回参数:bool 值为true时,表示保存成功;值为false表示保存失败设置保存路径public bool setdsavepath(string dsavepath)方法功能:设
4、置文档保存路径 注意是相对还是绝对 (还是有点疑问,是否要放在系统配置中)输入参数:string dsavepath 文档保存路径返回参数:bool 值为true表示设置成功;值为false表示设置失败 地图文档打印private function mapprint()on error goto errorhandler if pagelayoutctrl.printer is nothing then msgbox 没有打印机, , 提示 exit function end if dim pprinter as iprinter set pprinter = pagelayoutctrl.p
5、rinter if pprinter.paper.orientation pagelayoutctrl.page.orientation then pprinter.paper.orientation = pagelayoutctrl.page.orientation end if dim dwidth as double, dheight as double pprinter.querypapersize dwidth, dheight pagelayoutctrl.printpagelayout 打印 pagelayoutctrl.mousepointer = esripointerdef
6、ault exit functionerrorhandler: erroroperate err.description, erl, c_smodulefilename, mapprintsettingend function地图文档打印设置private function mapprintsetting()on error goto errorhandler if not showprinterset then exit function 如果取消就退出 if pagelayoutctrl.printer is nothing then msgbox 没有打印机, , 提示 exit fun
7、ction end if dim dwidth as double, dheight as double, iunits as integer dim pprinter as iprinter set pprinter = pagelayoutctrl.printer pprinter.paper.formid = printer.papersize pprinter.paper.orientation = printer.orientation dwidth = pprinter.paper.printablebounds.envelope.width dheight = pprinter.
8、paper.printablebounds.envelope.height with pagelayoutctrl.page .formid = esripageformcustom 自定义纸张大小(看到的) iunits = .units .units = pprinter.units .orientation = pprinter.paper.orientation .putcustomsize dwidth, dheight .stretchgraphicswithpage = false .querysize dwidth, dheight end with dim pframeele
9、ment as iframeelement dim pelement as ielement dim pmapframe as imapframe set pframeelement = pagelayoutctrl.activeview.graphicscontainer.findframe(pagelayoutctrl.activeview.focusmap) if not (pframeelement is nothing) then set pmapframe = pframeelement set pelement = pmapframe dim penvelope as ienve
10、lope set penvelope = pelement.geometry.envelope with penvelope .height = dheight - .ymin * 2 根据纸张变化重新设定地图框大小 .width = dwidth - .xmin * 2 end with pelement.geometry = penvelope dim pgraphicscontainer as igraphicscontainer set pgraphicscontainer = pagelayoutctrl.pagelayout pgraphicscontainer.updateele
11、ment pelement end if pagelayoutctrl.page.units = iunits pagelayoutctrl.activeview.refresh exit functionerrorhandler: if err.number = 32755 then exit function user pressed cancel erroroperate err.description, erl, c_smodulefilename, mapprintsettingend function二、 pagelayout模版切合(maps类)、视图切换public funct
12、ion f_pagelayout_createenvelope(pagelayoutcontrol1 as ipagelayoutcontrol2, lxmin as long, lymin as long, lxmax as long, lymax as long) as ienvelope函数功能:创建一个范围编写人 helen编写日期 2004/5/25 set f_pagelayout_createenvelope = nothing get the ipoint interface by creating points is the current page units dim pp
13、ointmin as ipoint dim ppointmax as ipoint set ppointmin = pagelayoutcontrol1.topagepoint(lxmin, lymin) set ppointmax = pagelayoutcontrol1.topagepoint(lxmax, lymax) get the ienvelope interface dim penvelope as ienvelope set penvelope = new envelope set the envelope coordinates penvelope.putcoords ppo
14、intmin.x, ppointmin.y, ppointmax.x, ppointmax.y set f_pagelayout_createenvelope = penvelopeend functionpublic function changelayout(optional firstpath as string) as integer函数功能: 切换地图模版编写人 wufayun编写日期 2006/04/02参数: optional firstpath as string 初始化打开对话框的路径返回值: = -1 地图模版路径为空;= -3 您加载的地图模版文件有错误;= -2 用户单
15、击的是取消;= -4 未知错误;= 1 成功on error goto errorhandlerfirstpath初始路径 commondialog1.dialogtitle = 打开地图模版 commondialog1.filter = 地图模版 (*.mxt)|*.mxt commondialog1.initdir = firstpath commondialog1.cancelerror = true commondialog1.showopen exit if no map document is selected dim mxtfilepath as string mxtfilepa
16、th = commondialog1.filename if mxtfilepath = then changelayout = -1 地图模版路径为空 exit function end if if not pagelayoutctrl.checkmxfile(mxtfilepath) then changelayout = -3 您加载的地图模版文件有错误 exit function end if pagelayoutctrl.loadmxfile mxtfilepath dim pmaps as imaps set pmaps = new maps dim pmap as imap se
17、t pmap = m_pmapdocument.map(0) pmaps.add pmap pagelayoutctrl.pagelayout.replacemaps pmaps pagelayoutctrl.activeview.activate pagelayoutctrl.hwnd m_pmapdocument.replacecontents pagelayoutctrl.pagelayout toccontrol1.setbuddycontrol pagelayoutctrl changelayout = 1 成功 exit functionerrorhandler: if err.n
18、umber = cdlcancel then 判断用户单击的是取消 changelayout = -2 用户单击的是取消 else changelayout = -4 未知错误 end ifend function三、 地图管理lxmap class接口 imap iactiveview功能:地图输出为图片、比例尺设置、显示单位设置、地图空间参考设置新建并添加图层组、添加图层、移去图层、图层顺序调整(功能性的)地图输出为图片public bool exportmaptofile(string pfilename)方法功能:把地图导出到指定格式的图象文件中(*.jpg;*.pdf;*.bmp;*
19、.tif) 注:使用iexporter的接口,比如用jpegexporter实例化,把地图转换成jpg输入参数:pfilename type string,图象文件全名返回参数:bool参数示例: pfilename=d:aa.bmp(此处应该是反斜线的单线吧)比例尺设置public bool setmapscale(double pscale)方法功能:地图比例尺设置输入参数:double pscale 比例尺大小返回参数:bool要加获取比例尺么public ispatialreference getmapprj(integer pzone, integer pzonetype,integ
20、er iprj )方法功能:设置地图空间参考输入参数:integer pzone 表示带号integer pzonetype 值为1 表示 3度带 值为2 表示 6度带integer iprj iprj=1表示北京54 iprj=2 表示西安80返回参数:ispatialreferencepublic ispatialreference getmapprj(imap pmap)方法功能:获取地图空间参考输入参数:imap pmap返回参数:ispatialreferencepublic function f_coordinate_getunitdescription(punits as esr
21、iunits) as string函数功能:显示单位设置on error goto eh f_coordinate_getunitdescription = 未知 select case punits case esriinches: f_coordinate_getunitdescription = 英寸 case esripoints: f_coordinate_getunitdescription = 点 case esrifeet: f_coordinate_getunitdescription = 英尺 case esriyards: f_coordinate_getunitdesc
22、ription = 码 case esrimiles: f_coordinate_getunitdescription = 英里 case esrinauticalmiles: f_coordinate_getunitdescription = 海里 case esrimillimeters: f_coordinate_getunitdescription = 毫米 case esricentimeters: f_coordinate_getunitdescription = 厘米 case esrimeters: f_coordinate_getunitdescription = 米 cas
23、e esrikilometers: f_coordinate_getunitdescription = 公里 case esridecimaldegrees: f_coordinate_getunitdescription = 度 case esridecimeters: f_coordinate_getunitdescription = 度 case esriunknownunits: f_coordinate_getunitdescription = 未知 case else: f_coordinate_getunitdescription = 未知 end selecteh:end fu
24、nction地图刷新public function maprefresh() as boolean dim pactiveview as iactiveview maprefresh = false if m_map is nothing then exit function set pactiveview = m_map pactiveview.refresh maprefresh = trueend function放大地图public function mapzoomin() dim point1 as ipoint dim lzoominkey as long dim penvelop
25、e as ienvelope lzoominkey = getkeystate(vbkeyadd) if lzoominkey and &h8000 then set point1 = new point point1.x = mapctrl.extent.xmin + mapctrl.extent.width / 2 point1.y = mapctrl.extent.ymin + mapctrl.extent.height / 2 set penvelope = mapctrl.activeview.extent penvelope.height = penvelope.height /
26、1.5 penvelope.width = penvelope.width / 1.5 penvelope.centerat point1 mapctrl.activeview.extent = penvelope mapctrl.activeview.partialrefresh esriviewgeography, nothing, nothing mapctrl.activeview.refresh end if set point1 = nothing set penvelope = nothingend function放大地图public function mapzoomout()
27、 dim point1 as ipoint dim lzoomoutkey as long dim penvelope as ienvelope lzoomoutkey = getkeystate(vbkeysubtract) if lzoomoutkey and &h8000 then set point1 = new point point1.x = mapctrl.extent.xmin + mapctrl.extent.width / 2 point1.y = mapctrl.extent.ymin + mapctrl.extent.height / 2 set penvelope =
28、 mapctrl.activeview.extent penvelope.height = penvelope.height * 1.5 penvelope.width = penvelope.width * 1.5 penvelope.centerat point1 mapctrl.activeview.extent = penvelope mapctrl.activeview.partialrefresh esriviewgraphics, nothing, nothing mapctrl.activeview.refresh end if set point1 = nothing set
29、 penvelope = nothingend function下移地图public function mapmovedown() dim point1 as ipoint dim ldownkey as long dim penvelope as ienvelope ldownkey = getkeystate(vbkeydown) if ldownkey and &h8000 then set point1 = new point point1.x = mapctrl.extent.xmin + mapctrl.extent.width / 2 point1.y = mapctrl.ext
30、ent.ymin + mapctrl.extent.height / 2 - mapctrl.extent.height / 5 mapctrl.centerat point1 mapctrl.activeview.partialrefresh esriviewgraphics, nothing, nothing end if set point1 = nothing set penvelope = nothingend function左移地图public function mapmoveleft() dim point1 as ipoint dim lleftkey as long dim
31、 penvelope as ienvelope lleftkey = getkeystate(vbkeyleft) if lleftkey and &h8000 then set point1 = new point point1.x = mapctrl.extent.xmin + mapctrl.extent.width / 2 - mapctrl.extent.width / 5 point1.y = mapctrl.extent.ymin + mapctrl.extent.height / 2 mapctrl.centerat point1 mapctrl.activeview.part
32、ialrefresh esriviewgraphics, nothing, nothing end if set point1 = nothing set penvelope = nothingend function右移地图public function mapmoveright() dim point1 as ipoint dim lrightkey as long dim penvelope as ienvelope lrightkey = getkeystate(vbkeyright) if lrightkey and &h8000 then set point1 = new poin
33、t point1.x = mapctrl.extent.xmin + mapctrl.extent.width / 2 + mapctrl.extent.width / 5 point1.y = mapctrl.extent.ymin + mapctrl.extent.height / 2 mapctrl.centerat point1 mapctrl.activeview.partialrefresh esriviewgraphics, nothing, nothing end if set point1 = nothing set penvelope = nothingend functi
34、on上移地图public function mapmoveup() dim point1 as ipoint dim lupkey as long dim penvelope as ienvelope lupkey = getkeystate(vbkeyup) if lupkey and &h8000 then set point1 = new point point1.x = mapctrl.extent.xmin + mapctrl.extent.width / 2 point1.y = mapctrl.extent.ymin + mapctrl.extent.height / 2 + m
35、apctrl.extent.height / 5 mapctrl.centerat point1 mapctrl.activeview.partialrefresh esriviewgraphics, nothing, nothing end if set point1 = nothing set penvelope = nothingend functiongetallfeaturelgetallrasterlgetfeaturel四、 图层管理lxlayer class接口 ilayer ifeaturelayer irasterlayer功能:获得图层、可见比例尺范围设置、数据源设置、可
36、见性设置、可选性设置、透明度设置、图层可见要素设置、public function f_layer_getlayername(player as ilayer, playernametype as integer) as string f_layer_getlayername = if player is nothing then exit function dim i_labelname as string 图层的layer别名 dim i_datasetname as string 图层的dataset名 dim i_datasetfullname as string 图层的dataset
37、全名 dim i_layerfullname as string 图层的(layer别名+dataset全名) dim i_wsname as string 图层所在数据库带路径的全名 i_labelname = player.name if typeof player is ifeaturelayer then dim i_featurelayer as ifeaturelayer set i_featurelayer = player if i_featurelayer is nothing then exit function dim i_featureclass as ifeature
38、class set i_featureclass = i_featurelayer.featureclass if i_featureclass is nothing then exit function dim i_dataset as idataset set i_dataset = i_featureclass if i_dataset is nothing then exit function dim i_workspace as iworkspace set i_workspace = i_dataset.workspace if i_workspace is nothing the
39、n exit function i_datasetname = i_dataset.name i_datasetfullname = i_workspace.pathname & - & i_dataset.name i_wsname = i_workspace.pathname elseif typeof player is irasterlayer then dim i_rasterlayer as irasterlayer set i_rasterlayer = player if i_rasterlayer is nothing then exit function dim i_ras
40、ter as iraster set i_raster = i_rasterlayer.raster if i_raster is nothing then exit function i_datasetname = i_rasterlayer.filepath end if i_layerfullname = i_labelname & , & i_datasetfullname if playernametype = 1 then f_layer_getlayername = i_labelname if playernametype = 2 then f_layer_getlayerna
41、me = i_datasetfullname if playernametype = 3 then f_layer_getlayername = i_labelname & , & i_datasetfullname if playernametype = 4 then f_layer_getlayername = i_datasetname if playernametype = 5 then f_layer_getlayername = i_wsname 显示该图层所在的组名 dim i_grouplayer as igrouplayer set i_grouplayer = f_laye
42、r_getlayergroup(papp, player) if not (i_grouplayer is nothing) then f_layer_getlayername = i_grouplayer.name & : & f_layer_getlayername end if end function函数功能: 对map中所有图层进行可选或不可选中的操作public sub f_map_selectablesetalllayers(pmap as imap, pselect as boolean) if pmap is nothing then exit sub if pmap.lay
43、ercount = 0 then exit sub dim i_layerindex as integer for i_layerindex = 0 to pmap.layercount - 1 dim i_layer as ilayer set i_layer = pmap.layer(i_layerindex) f_layer_selectablesetlayer i_layer, pselect nextend subgetallfeaturelgetallrasterlgetfeaturelpublic function f_layer_getallotherlayersfrommap
44、(byval pmap as imap, byval leibie as integer, optional playername as string) as icompositelayer函数名称 f_layer_getallfeaturelayersfrommap(byval pmap as imap, byval forestlayer as string) as igrouplayer函数功能 从当前图层中获得所有图层,或所有矢量图层,或所有林业专业图层编写人 wufayun编写日期 2006/3/18输入参数 byval leibie =1表示:从当前图层中获得所有图层,=2表示:所
45、有矢量图层,=3表示:所有林业专业图层 =4表示获得指定图层名的图层返回值on error goto eh dim pgrouplayer as igrouplayer dim i as integer dim j as integer dim pcompositelayer as icompositelayer dim player as ilayer dim m_layergeneralproperties as ilayergeneralproperties dim forest as string dim playerdescription as string dim a as int
46、eger5 set pcompositelayer = nothing set pgrouplayer = new grouplayer for i = 0 to pmap.layercount - 1 if typeof pmap.layer(i) is icompositelayer then set pcompositelayer = pmap.layer(i) for j = 0 to pcompositelayer.count - 1 set player = pcompositelayer.layer(j) if leibie = 1 then pgrouplayer.add pl
47、ayer elseif leibie = 2 then if typeof player is ifeaturelayer then pgrouplayer.add player end if elseif leibie = 3 then if typeof player is ifeaturelayer then set m_layergeneralproperties = player playerdescription = m_layergeneralproperties.layerdescription forest = 林业专业 a = instr(1, playerdescription, forest, vbtextcompare) if a 0 then pgrouplayer.add player end if end if elseif leibie = 4
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 嵌入式应用场景试题及答案
- 计算机三级考试注意事项试题及答案
- 2024–2025年中国数据标注产业深度分析报告
- 组织中的冲突管理与领导策略试题及答案
- 电子商城销售商品采购合同
- 家庭学习计划(4篇)
- 环境工程水处理技术实务试题
- 物流管理理论及应用测试题
- 测试工具的性能评估方法试题及答案
- 数据库表的设计与增强方法试题及答案
- 植物分子育种策略-全面剖析
- 三方协议空白合同
- 挡烟垂壁施工合同
- 社工招聘笔试题目及答案
- 八省联考模拟试题及答案
- JGJ46-2024施工现场临时用电安全技术标准宣讲课件
- 2024北京西城区三年级(下)期末语文试题及答案
- 初中化学跨学科教学实践活动设计与实施研究
- GB/T 15180-2025重交通道路石油沥青
- 劳动合同正规版(2025年版)
- 神经外科医师职业发展计划
评论
0/150
提交评论