wzhglove
路人甲
路人甲
  • 注册日期2005-02-19
  • 发帖数11
  • QQ
  • 铜币125枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1722回复:1

小弟正学MO,学到缓冲区分析的时候遇到问题了

楼主#
更多 发布于:2006-04-20 22:56
<P>我按书上给的代码,一个一个字的敲上去,</P>
<P>却的不到要的效果,代码如下,哪位帮忙分析下原因,</P>
<P>不胜感激</P>

<P>Option Explicit</P>
<P><BR>Private Sub Form_Load()<BR>Dim dc As New DataConnection<BR>Dim layer1 As New MapObjects2.MapLayer<BR>Dim layer2 As New MapObjects2.MapLayer</P>
<P> dc.Database = "d:\modata\mexico"<BR> <BR> If dc.Connect Then</P>
<P>    Set layer1.GeoDataset = dc.FindGeoDataset("states")<BR>    Set layer2.GeoDataset = dc.FindGeoDataset("rivers")<BR>    <BR>    layer1.Symbol.Color = vbGreen<BR>    layer2.Symbol.Color = vbRed<BR>    Map1.Layers.Add layer1<BR>    Map1.Layers.Add layer2<BR> End If<BR> <BR> <BR> Option1.Caption = "点"<BR> Option2.Caption = "线"<BR> Option3.Caption = "矩形"<BR> Option4.Caption = "多边形"<BR> Option5.Caption = "椭圆"<BR> Text1.Text = "10000"<BR> <BR> <BR> Map1.TrackingLayer.SymbolCount = 4<BR> <BR> With Map1.TrackingLayer.Symbol(0)<BR>     .SymbolType = moPointSymbol<BR>     .Style = moTriangleMarker<BR>     .Color = moRed<BR>     .Size = 3<BR> End With<BR> <BR> With Map1.TrackingLayer.Symbol(1)<BR>     .SymbolType = moLineSymbol<BR>     <BR>     .Color = moRed<BR>     .Size = 3<BR>  End With<BR>  <BR> With Map1.TrackingLayer.Symbol(2)<BR>     .SymbolType = moFillSymbol<BR>     .Style = moGrayFill<BR>     .Color = moRed<BR>     .OutlineColor = moRed<BR> End With<BR> <BR> With Map1.TrackingLayer.Symbol(3)<BR>     .SymbolType = moFillSymbol<BR>     .Style = moGrayFill<BR>     .Color = moBlue<BR>     .OutlineColor = moBlue<BR> End With<BR>     <BR>     <BR>     <BR> <BR>End Sub</P>
<P>Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)</P>
<P><BR>If Option1.Value Then<BR>Dim pt As New MapObjects2.Point<BR>Dim eventPt As New MapObjects2.GeoEvent</P>
<P>Dim buffPt As New MapObjects2.Polygon<BR>Dim buffEventPt As New MapObjects2.GeoEvent</P>
<P>Set pt = Map1.ToMapPoint(X, Y)<BR>Set eventPt = Map1.TrackingLayer.AddEvent(pt, 0)</P>
<P>Set buffPt = pt.Buffer(Text1.Text, Map1.FullExtent)<BR>Set buffEventPt = Map1.TrackingLayer.AddEvent(buffPt, 3)</P>

<P><BR>ElseIf Option2.Value Then<BR>Dim line As New MapObjects2.line<BR>Dim eventLine As New MapObjects2.GeoEvent</P>
<P>Dim buffLine As New MapObjects2.Polygon<BR>Dim buffLineEvent As New MapObjects2.GeoEvent</P>
<P>Set line = Map1.TrackLine<BR>Set eventLine = Map1.TrackingLayer.AddEvent(line, 1)</P>
<P>Set buffLine = line.Buffer(Text1.Text, Map1.FullExtent)<BR>Set buffLineEvent = Map1.TrackingLayer.AddEvent(buffLine, 3)</P>

<P>ElseIf Option3.Value Then<BR>Dim rect As New MapObjects2.Rectangle<BR>Dim rectEvent As New MapObjects2.GeoEvent</P>
<P>Dim rectBuff As New MapObjects2.Polygon<BR>Dim rectBuffEvent As New MapObjects2.GeoEvent</P>
<P>Set rect = Map1.TrackRectangle<BR>Set rectEvent = Map1.TrackingLayer.AddEvent(rect, 2)</P>
<P>Set rectBuff = rect.Buffer(Text1.Text, Map1.FullExtent)<BR>Set rectBuffEvent = Map1.TrackingLayer.AddEvent(rectBuff, 3)</P>
<P>ElseIf Option4.Value Then<BR>Dim poly As New MapObjects2.Polygon<BR>Dim polyEvent As New MapObjects2.GeoEvent</P>
<P>Dim polybuff As New MapObjects2.Polygon<BR>Dim polybuffEvent As New MapObjects2.GeoEvent</P>
<P>Set poly = Map1.TrackPolygon<BR>Set polyEvent = Map1.TrackingLayer.AddEvent(poly, 2)</P>
<P>Set polybuff = poly.Buffer(Text1.Text, Map1.FullExtent)<BR>Set polybuffEvent = Map1.TrackingLayer.AddEvent(polybuff, 3)</P>
<P>ElseIf Option5.Value Then<BR>Dim arcrt As New MapObjects2.Rectangle<BR>Dim elli As New MapObjects2.Ellipse<BR>Dim elliEvent As New MapObjects2.GeoEvent</P>
<P>Dim ellibuff As New MapObjects2.Polygon<BR>Dim ellibuffEvent As New MapObjects2.GeoEvent</P>
<P>Set arcrt = Map1.TrackRectangle<BR>elli.Top = arcrt.Top<BR>elli.Bottom = arcrt.Bottom<BR>elli.Left = arcrt.Left<BR>elli.Right = arcrt.Right</P>
<P>Set elliEvent = Map1.TrackingLayer.AddEvent(elli, 2)</P>
<P>Set ellibuff = elli.Buffer(Text1.Text, Map1.FullExtent)<BR>Set ellibuffEvent = Map1.TrackingLayer.AddEvent(ellibuff, 3)</P>
<P><BR>End If<BR>End Sub<BR></P>

喜欢0 评分0
冰+冰
路人甲
路人甲
  • 注册日期2006-03-11
  • 发帖数87
  • QQ
  • 铜币335枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2006-05-27 09:21
<P>你都没说要达到什么样的效果~ </P>
举报 回复(0) 喜欢(0)     评分
游客

返回顶部