阅读:1551回复:3
[求助]9958,vb+mo中如何显示两图层的公共符合要求部分
<P>其中加载图层的部分省略了</P>
<P>Option Explicit<BR>Dim resultShape1 As MapObjects2.Polygon '一下是声明一些变量<BR>Dim resultShape2 As MapObjects2.Polygon<BR>Dim resultShape As MapObjects2.Polygon</P> <P><BR>Dim recSelection As MapObjects2.Recordset<BR>Dim recSelection1 As MapObjects2.Recordset</P> <P>Dim intersectShape As MapObjects2.Polygon<BR>Dim intersectShape1 As MapObjects2.Polygon<BR>Dim rect As MapObjects2.Rectangle</P> <P>Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)</P> <P> Dim strExpression As String<BR> Dim strExpression1 As String<BR> 'Dim Ai As Single<BR> 'Const Ak = 1000<BR> <BR> Set rect = Map1.TrackRectangle<BR> strExpression = "适宜性='无公害'"<BR> strExpression1 = "状况='一般'"<BR> <BR> Set recSelection = Map1.Layers("wly_Project").SearchExpression(strExpression)<BR> Set intersectShape = recSelection.Fields("shape").Value<BR> <BR> <BR> <BR> Set recSelection1 = Map1.Layers("耕地地力_Project").SearchExpression(strExpression1)<BR> Set intersectShape1 = recSelection.Fields("shape").Value<BR> <BR> <BR> '求得两图层符合条件的公共部分 主要就是这一句,希望能得到就结果<BR> Set resultShape = intersectShape.Intersect(intersectShape1)</P> <P> Map1.Refresh<BR><BR></P> <P> If Not recSelection Is Nothing Then '先将图层符合条件的部分分别以不同的色显示<BR> sym1.Color = moOrange<BR> Map1.DrawShape recSelection, sym1<BR> End If</P> <P><BR> <BR> If Not recSelection1 Is Nothing Then<BR> sym1.Color = moGreen<BR> <BR> Map1.DrawShape recSelection, sym1<BR> End If</P> <P> If Not resultShape Is Nothing Then '以红色显示两图层符合条件的公共部分<BR> sym1.Color = moRed<BR> Map1.DrawShape resultShape, sym1<BR> End If</P> <P>End Sub</P> |
|
1楼#
发布于:2008-05-30 15:11
我也需要这方面的东西,真是好着急啊,上面的朋友可解决出来了啊。
|
|
2楼#
发布于:2008-01-20 17:35
<P>我都查了啊,怎么还是不行的呢,我找不出原因啊。。。。。</P>
<P>哪位高手帮帮忙啊,。。。</P> <img src="images/post/smile/dvbbs/em02.gif" /> [此贴子已经被作者于2008-1-21 20:26:35编辑过]
|
|
3楼#
发布于:2008-01-16 21:27
代码思路看上去应该没什么问题;只能自己逐步查看是否都得到想要的结果了,查看问题到底在哪里<br><br>建议: Set recSelection = Map1.Layers("wly_Project").SearchExpression(strExpression)<br>像这种最好是分开两句写,<br>MapObjects2.MapLayer ml = map1.layers(0);<br>recSelecction = ml.sertchExpression("");<br><br>还有你的图层是否符合你的要求,多查查吧<br>
|
|
|