阅读:3759回复:9
[分享]vb。net+mo的实现选择功能
<DIV>
<P><FONT face=宋体> '<BR> '定义变量实现选择功能<BR> '</FONT></P> <P><FONT face=宋体> Dim selpnt As MapObjects2.Point<BR> Dim lar As MapObjects2.MapLayer<BR> Dim resultshps As Collection<BR> Dim resultshp As Object<BR> Dim recs As MapObjects2.Recordset<BR> Dim loc As MapObjects2.Point<BR> Dim shppoint As MapObjects2.Point<BR> Dim shpline As MapObjects2.Line<BR> Dim shppoly As MapObjects2.Polygon<BR> Dim myline As MapObjects2.Line<BR> Dim recshap As MapObjects2.Recordset</FONT></P> <P><FONT face=宋体> 'axmap1上的单击事件函数集合<BR> '<BR> '<BR> Private Sub AxMap1_MouseDownEvent(ByVal sender As Object, ByVal e As AxMapObjects2._DMapEvents_MouseDownEvent) Handles AxMap1.MouseDownEvent<BR> Dim sym1 As MapObjects2.Symbol<BR> shppoint = New MapObjects2.Point<BR> shpline = New MapObjects2.Line<BR> shppoly = New MapObjects2.Polygon<BR> sym1 = New MapObjects2.Symbol<BR> lar = New MapObjects2.MapLayerClass<BR> selpnt = New MapObjects2.Point<BR> Select Case flag<BR> Case 2 '放大<BR> rcg = AxMap1.TrackRectangle<BR> AxMap1.Extent = rcg<BR> AxMap1.Refresh()</FONT></P> <P><FONT face=宋体> Case 3 '缩小<BR> roc = AxMap1.ToMapPoint(e.x, e.y)<BR> rcg = AxMap1.Extent<BR> rcg.ScaleRectangle(1.5)<BR> AxMap1.Extent = rcg</FONT></P> <P><FONT face=宋体> Case 7 '移动<BR> AxMap1.Pan()<BR> Case 4 '实现图形的选择功能<BR> lar = AxMap1.Layers.Item(0)<BR> If lar.shapeType = MapObjects2.ShapeTypeConstants.moShapeTypePoint Then<BR> rcg = AxMap1.TrackRectangle<BR> recs = lar.SearchShape(rcg, MapObjects2.SearchMethodConstants.moContaining, "")<BR> sym1.SymbolType = MapObjects2.SymbolTypeConstants.moPointSymbol<BR> shppoint = recs.Fields.Item("Shape").Value<BR> AxMap1.FlashShape(shppoint, 3)<BR> 'AxMap1.DrawShape(shp, sym)<BR> 'AxMap1.TrackingLayer.Refresh(True)<BR> 'AxMap1.TrackingLayer.AddEvent(shp, 0)<BR> 'AxMap1.DrawShape(shp, sym)<BR> 'AxMap1.TrackingLayer.Refresh(True)<BR> ElseIf lar.shapeType = MapObjects2.ShapeTypeConstants.moShapeTypeLine Then<BR> myline = AxMap1.TrackLine<BR> recs = lar.SearchShape(myline, MapObjects2.SearchMethodConstants.moLineCross, "")<BR> shpline = recs.Fields.Item("Shape").Value<BR> AxMap1.FlashShape(shpline, 3)<BR> 'AxMap1.TrackingLayer.Refresh(True)<BR> 'AxMap1.TrackingLayer.AddEvent(shp, 0)<BR> ElseIf lar.shapeType = MapObjects2.ShapeTypeConstants.moShapeTypePolygon Then<BR> selpnt = AxMap1.ToMapPoint(e.x, e.y)<BR> recs = lar.SearchShape(selpnt, MapObjects2.SearchMethodConstants.moPointInPolygon, "")<BR> shppoly = recs.Fields.Item("Shape").Value<BR> AxMap1.FlashShape(shppoly, 3)<BR> 'AxMap1.TrackingLayer.Refresh(True)<BR> 'AxMap1.TrackingLayer.AddEvent(shp, 0)<BR> 'AxMap1.FlashShape(selpnt, 2)<BR> End If<BR> AxMap1.Refresh()<BR> Case 5 '分割图形<BR> </FONT><FONT face=宋体>Case 6 ' 合并图形<BR> End Select<BR> AxMap1.TrackingLayer.Refresh(True)<BR> End Sub</FONT></P> <P>''''以下是实现显示我们所选择的图形</P> <P><FONT face=宋体> Private Sub AxMap1_AfterTrackingLayerDraw(ByVal sender As Object, ByVal e As AxMapObjects2._DMapEvents_AfterTrackingLayerDrawEvent) Handles AxMap1.AfterTrackingLayerDraw<BR> Dim i As Integer<BR> Dim p As MapObjects2.Point<BR> Dim ps As MapObjects2.Points<BR> p = New MapObjects2.Point<BR> ps = New MapObjects2.Points<BR> Dim sym As MapObjects2.Symbol<BR> Dim sym2 As MapObjects2.Symbol<BR> sym2 = New MapObjects2.Symbol<BR> sym2.Color = System.UInt32.Parse(color.moRed)<BR> sym = New MapObjects2.Symbol<BR> sym.Color = System.UInt32.Parse(color.moBlue)<BR> 'sym.Color = m_grid.Color<BR> Select Case flag<BR> Case 4 '显示所选择的图形<BR> lar = AxMap1.Layers.Item(0)<BR> If lar.shapeType = MapObjects2.ShapeTypeConstants.moShapeTypePoint Then<BR> AxMap1.DrawShape(shppoint, sym)<BR> ElseIf lar.shapeType = MapObjects2.ShapeTypeConstants.moShapeTypeLine Then<BR> AxMap1.DrawShape(shpline, sym)<BR> ElseIf lar.shapeType = MapObjects2.ShapeTypeConstants.moShapeTypePolygon Then<BR> AxMap1.DrawShape(shppoly, sym)<BR> End If<BR> Case 5 '分割图形 </FONT></P> <P><FONT face=宋体> End Select</FONT></P> <P><FONT face=宋体><BR> End Sub</FONT></P> <P>以上的程序,有的是我自已写的,有的是改MO自带的例子的,大家可以给点意见,也可以和我一起讨论一下,在VB.NET中MAPOBJECT的应用</P></DIV> |
|
|
1楼#
发布于:2007-04-17 22:57
功能比较简单,但是对初学者很有用,加精了<img src="images/post/smile/dvbbs/em02.gif" />
|
|
|
2楼#
发布于:2007-04-18 11:35
<P>谢谢</P>
<P>功能很简单,也是我的心血啊,</P> |
|
|
3楼#
发布于:2007-04-18 21:25
<P>希望你多来这里交流,不过ESRI已经停止对MO的更新了</P>
|
|
|
4楼#
发布于:2007-04-21 21:18
<P>顶住</P><img src="images/post/smile/dvbbs/em01.gif" /> |
|
5楼#
发布于:2007-05-24 08:20
有没有AO的啊 ?谢谢 呵呵
|
|
6楼#
发布于:2007-05-24 11:17
楼上要了解ao,请到arcgis和arcobjects版面搜索下
|
|
|
7楼#
发布于:2007-07-24 15:38
<P>那现在学MO还有用不?</P>
|
|
8楼#
发布于:2008-03-18 17:28
<img src="images/post/smile/dvbbs/em01.gif" /><img src="images/post/smile/dvbbs/em02.gif" />
|
|
9楼#
发布于:2008-03-20 10:15
<P>基本没用了!</P>
|
|