阅读:3929回复:11
图层分组的问题。帮忙近来看看。
怎样把图层layer1和图层layer2合并成一个组layer.用代码怎么实现??
给个例子或是提示,,谢谢啦。。请教斑竹!!<img src="images/post/smile/dvbbs/em01.gif" /><img src="images/post/smile/dvbbs/em01.gif" /><img src="images/post/smile/dvbbs/em02.gif" /><img src="images/post/smile/dvbbs/em02.gif" /><img src="images/post/smile/dvbbs/em02.gif" /> |
|
1楼#
发布于:2004-08-14 20:22
<P>请大家支持一下。。。给顶下啊。。说点自己的看法也行啊。。。</P><P>我看了半天IGROUPLAYER接口就是不明白怎么做。。请大吓帮忙看看。该怎么用?</P><img src="images/post/smile/dvbbs/em02.gif" />
|
|
2楼#
发布于:2004-08-16 15:16
下面的代码可以参考一下。
The following example is a code excerpt that shows how to change the fine-grained ArcObjects (by adding a new group layer), and apply these changes to the MapServer object using RefreshServerObjects. It assumes that you are developing an ArcGIS Server application using a ServerContext, and already have a valid ServerContext, MapServer and MapDescription object. Dim pServerContext as IServerContext Dim pMapServer as IMapServer Dim pMapDesc as IMapDescription 'Access fine-grained ArcObjects Dim pMapServerObj As IMapServerObjects Set pMapServerObj = pMapServer Dim strMapName as string strMapName = pMapServer.DefaultMapName Dim pMap As IMap Set pMap = pMapServerObj.Map(strMapName) 'Add new group layer to map Dim pGroupLayer As IGrouplayer Set pGroupLayer = pServerContext.CreateObject("esriCarto.GroupLayer") pGroupLayer.Name = "New Group Layer" pMap.AddLayer pGroupLayer 'Apply changes to MapServer object pMapServerObj.RefreshServerObjects 'Get updated MapServerInfo and MapDescription Dim pMapServerInfo as IMapServerInfo Set pMapServerInfo = pMapServer.GetServerInfo(strMapName) Set pMapDesc = pMapServerInfo.DefaultMapDescription [此贴子已经被作者于2004-8-16 15:21:00编辑过]
|
|
|
3楼#
发布于:2004-08-16 15:38
<P>上面的代码容易弄混。看下这个吧。在VBA里做了简单测试,运得时最好加入三个以上测试图层。</P><P>Private Sub CommandButton1_Click()
On Error GoTo EH Dim pApp As IMxApplication Dim pMap As IMap</P><P> Dim pMxDocument As IMxDocument Set pApp = Application Set pMxDocument = ThisDocument Set pMap = pMxDocument.FocusMap </P><P> Dim pGLayer As IGroupLayer Set pGLayer = New GroupLayer pGLayer.Name = "Just For Test" pMap.AddLayer pGLayer pGLayer.Add pMap.Layer(pMap.LayerCount - 1) pGLayer.Add pMap.Layer(pMap.LayerCount - 2) pMxDocument.UpdateContents MsgBox "ok" Exit Sub EH: MsgBox Err.Description End Sub</P> |
|
|
4楼#
发布于:2004-08-16 18:37
<P>楼上的代码会出现这样的问题:</P><P>当你删除原图层时,加入GROUP LAYER 的图层也没有了。而且如果你删除了GROUP LAYER的图层时,原图层也找不到了。</P>
|
|
5楼#
发布于:2004-08-17 09:12
<P>只是简单地举例igrouplayer 的用法。哈。。</P>
<DIV class=quote>pGLayer.Add pMap.Layer(pMap.LayerCount - 1) pGLayer.Add pMap.Layer(pMap.LayerCount - 2) </DIV>测试用法当然是越简单越好,越快越好。但肯定会有一些问题。 [此贴子已经被作者于2004-8-17 9:14:29编辑过]
|
|
|
6楼#
发布于:2004-08-17 09:52
<P>问题市如何解决这样的问题啊。楼上高手请指点一二。</P><P>感谢中。。。。。</P>
|
|
7楼#
发布于:2004-08-17 13:09
<P>Private Sub CommandButton1_Click()
On Error GoTo EH Dim pApp As IMxApplication Dim pMap As IMap</P><P> Dim pMxDocument As IMxDocument Set pApp = Application Set pMxDocument = ThisDocument Set pMap = pMxDocument.FocusMap Dim pGupOp As IGroupLayersOperation Set pGupOp = New GroupLayersOperation</P><P>pGupOp.SourceMap = pMap Dim plyr1 As ILayer Set plyr1 = pMap.Layer(pMap.LayerCount - 1) Dim plyr2 As ILayer Set plyr2 = pMap.Layer(pMap.LayerCount - 2)</P><P>pGupOp.AddLayer plyr1 pGupOp.AddLayer plyr2</P><P>Dim pop As IOperation Set pop = pGupOp pop.Do</P><P>pMxDocument.UpdateContents Exit Sub EH: MsgBox Err.Description End Sub</P><P>其它的自已去考虑如何解决吧。</P><P><U><FONT color=#800080>GroupLayersOperation (esriArcMapUI)</FONT></U></P><P><U><FONT color=#800080><a href="http://arcgisdeveloperonline.esri.com/ArcGISDeveloper/ComponentHelp/esriArcMapUI/UngroupLayerOperation.htm" target="_blank" >UngroupLayerOperation (esriArcMapUI)</A></FONT></U></P><P><U><FONT color=#800080>...别人不可能帮你做好每件事情。</FONT></U></P><P><U><FONT color=#800080></FONT></U> </P> |
|
|
8楼#
发布于:2004-08-17 14:47
<img src="images/post/smile/dvbbs/em01.gif" /><img src="images/post/smile/dvbbs/em02.gif" />谢谢各位高手!!!!
|
|
9楼#
发布于:2004-08-17 22:20
<U><FONT color=#800080>GroupLayersOperation是arcgis9的接口了,在8.3中难道真的不能实现吗?</FONT></U>
[此贴子已经被作者于2004-8-17 22:35:40编辑过]
|
|
上一页
下一页