dengminjie
路人甲
路人甲
  • 注册日期2006-06-03
  • 发帖数14
  • QQ
  • 铜币172枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1005回复:0

[讨论]mo基本功能实现

楼主#
更多 发布于:2006-07-06 08:25
<P>Dim dc As New DataConnection<BR>Dim r As MapObjects2.Rectangle<BR>Dim layer As MapLayer</P>

<P>Private Sub Command1_Click()<BR>End<BR>End Sub</P>
<P>Private Sub Command2_Click()<BR>Map1.Layers.Clear<BR>layerset<BR>legend1.setMapSource Map1<BR>legend1.LoadLegend True<BR>Map1.Refresh<BR>Map2.Refresh</P>
<P>End Sub</P>
<P>Private Sub Command3_Click()<BR>Map1.Layers.Clear<BR>Map2.Layers.Clear<BR>legend1.LoadLegend False<BR>End Sub</P>
<P>Private Sub Form_Load()<BR>dc.Database = App.Path + "/../" + "MEXICO"<BR>If Not dc.Connect Then<BR>MsgBox "no data"<BR>End<BR>End If<BR>Map1.Refresh<BR>Map2.Refresh</P>
<P>End Sub</P>
<P>Private Sub layerset()</P>
<P>Set layer = New MapLayer<BR>layer.GeoDataset = dc.FindGeoDataset("states")<BR>layer.Name = "州界"<BR>layer.Symbol.Color = moYellow<BR>Map1.Layers.Add layer<BR>Map2.Layers.Add layer</P>
<P>Set layer = New MapLayer<BR>layer.GeoDataset = dc.FindGeoDataset("rivers")<BR>layer.Name = "河流"<BR>layer.Symbol.Color = moBlue<BR>layer.Symbol.Size = 1.5<BR>Map1.Layers.Add layer</P>
<P>Set layer = New MapLayer<BR>layer.GeoDataset = dc.FindGeoDataset("cities")<BR>layer.Symbol.Color = moRed<BR>layer.Name = "城市"<BR>Map1.Layers.Add layer</P>
<P>Set layer = New MapLayer<BR>layer.GeoDataset = dc.FindGeoDataset("cities")<BR>layer.Name = "城市名称"<BR>layer.Symbol.Color = moRed<BR>Set layer.Renderer = New LabelRenderer<BR>layer.Renderer.Field = "name"<BR>Map1.Layers.Add layer</P>
<P><BR>End Sub</P>
<P>Private Sub legend1_AfterSetLayerVisible(index As Integer, isVisible As Boolean)<BR>Map1.Refresh<BR>End Sub</P>
<P>Private Sub Map1_AfterLayerDraw(ByVal index As Integer, ByVal canceled As Boolean, ByVal hDC As stdole.OLE_HANDLE)<BR>If index = 0 Then<BR>Map2.TrackingLayer.Refresh True<BR>End If</P>
<P>Call refreshscale<BR>End Sub</P>
<P>Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)<BR>If Toolbar1.Buttons(1).Value = tbrPressed Then<BR>Map1.Extent = Map1.TrackRectangle<BR>ElseIf Toolbar1.Buttons(2).Value = tbrPressed Then<BR>Set r = Map1.Extent<BR>r.ScaleRectangle 1.5<BR>Map1.Extent = r<BR>ElseIf Toolbar1.Buttons(3).Value = tbrPressed Then<BR>Map1.Pan<BR>End If<BR>End Sub</P>
<P>Private Sub Map2_AfterTrackingLayerDraw(ByVal hDC As stdole.OLE_HANDLE)<BR>Dim sym As New Symbol<BR>sym.OutlineColor = moRed<BR>sym.Size = 2<BR>sym.Style = 1<BR>Map2.DrawShape Map1.Extent, sym</P>
<P><BR>End Sub</P>

<P>Private Sub Map2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)<BR>Dim pt As MapObjects2.Point<BR>Dim cur As MapObjects2.Rectangle</P>
<P>Set cur = Map2.TrackRectangle<BR>Set Map1.Extent = cur</P>
<P>Set pt = Map2.ToMapPoint(X, Y)<BR>Map1.CenterAt pt.X, pt.Y</P>
<P><BR>End Sub</P>
<P>Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)<BR>If Toolbar1.Buttons(1).Value = tbrPressed Then<BR>Map1.MousePointer = moZoomIn<BR>ElseIf Toolbar1.Buttons(2).Value = tbrPressed Then<BR>Map1.MousePointer = moZoomOut<BR>ElseIf Toolbar1.Buttons(3).Value = tbrPressed Then<BR>Map1.MousePointer = moPan<BR>ElseIf Toolbar1.Buttons(4).Value = tbrPressed Then<BR>Map1.Extent = Map1.FullExtent<BR>Map1.MousePointer = moDefault<BR>End If<BR>End Sub<BR>Private Sub refreshscale()<BR>ScaleBar1.MapExtent.MaxX = Map1.Extent.Right<BR>ScaleBar1.MapExtent.MinX = Map1.Extent.Left<BR>ScaleBar1.MapExtent.MaxY = Map1.Extent.Bottom<BR>ScaleBar1.MapExtent.MinY = Map1.Extent.Top</P>
<P>ScaleBar1.PageExtent.MinX = Map1.Left / Screen.TwipsPerPixelX<BR>ScaleBar1.PageExtent.MinY = Map1.Top / Screen.TwipsPerPixelY<BR>ScaleBar1.PageExtent.MaxX = (Map1.Left + Map1.Width) / Screen.TwipsPerPixelX<BR>ScaleBar1.PageExtent.MaxY = (Map1.Top + Map1.Height) / Screen.TwipsPerPixelY</P>
<P>ScaleBar1.Refresh<BR>End Sub<BR></P>
<P>这代码可以吗??</P>
喜欢0 评分0
游客

返回顶部