|
阅读:2109回复:6
MO+VB基础应用实例
<P><b><FONT size=+0><IMG src="http://gis.swjtu.edu.cn/emoticons/emotion-36.gif">MO标注功能实现</FONT></b></P>
<P>Annotation实例:在mo安装路径sample\VB\annotation目录下</P> <P>'The Annotation sample demonstrates the use of the LabelRenderer object to 'annotate linear features of a map. A ValueMapRenderer is also used to 'display the linear road features. The sample uses the 慣rails?sample data 'sets.</P> <P>'The sample provides the user with options to display text as scale-dependant 'or constant size, using the HeightField property. The user may also choose to 'display the text splined along the linear feature or not, using the 'SplinedText. The background MapLayer can be turned on or off, using the 'ShowBackground property.</P> <P>'请研究学习以下图层标注代码 Sub SetupLayers() ' load data into the map Dim dc As New DataConnection dc.Database = ReturnDataPath("trails") If Not dc.Connect Then End Dim layer As New MapLayer Set layer.GeoDataset = dc.FindGeoDataset("roads") Map1.Layers.Add layer</P> <P> Set layer = New MapLayer Set layer.GeoDataset = dc.FindGeoDataset("anno") Map1.Layers.Add layer</P> <P>End Sub</P> <P>Sub SetupRenderers() ' ' set up renderer for roads ' ' Set ly = Map1.Layers("roads") Set ly.Renderer = New ValueMapRenderer ly.Renderer.SymbolType = moLineSymbol ly.Renderer.Field = "TYPE" ' set the values ly.Renderer.ValueCount = 4 ly.Renderer.Value(0) = "Dirt Road" ly.Renderer.Value(1) = "Highway" ly.Renderer.Value(2) = "Paved Road" ly.Renderer.Value(3) = "Single Track" ' set the symbols ly.Renderer.Symbol(0).Color = moRed ly.Renderer.Symbol(1).Color = moDarkGreen ly.Renderer.Symbol(1).Size = 2 ly.Renderer.Symbol(2).Color = moDarkGreen ly.Renderer.Symbol(3).Color = moOrange ' ' ' set up renderer for anno ' ' Set ly = Map1.Layers("anno") ly.Symbol.Color = moCyan Set ly.Renderer = New LabelRenderer ly.Renderer.DrawBackground = False ly.Renderer.Field = "TEXT" ly.Renderer.HeightField = "HEIGHT" Set sym = ly.Renderer.Symbol(0) Dim txtFont As New StdFont txtFont.Name = "Times" sym.Font = txtFont</P> <P>End Sub</P> <P>Private Sub Check1_Click() Set r = Map1.Layers("anno").Renderer r.SplinedText = Check1.Value = 1 Map1.Refresh End Sub</P> <P>Private Sub Check2_Click() Set r = Map1.Layers("anno").Renderer If Check2.Value = 1 Then r.HeightField = "HEIGHT" Else r.HeightField = "" End If Map1.Refresh</P> <P>End Sub</P> <P> Private Sub Check3_Click() Set r = Map1.Layers("anno").Renderer r.DrawBackground = Check3.Value = 1 Map1.Refresh</P> <P>End Sub</P> <P>Private Sub Command1_Click() Map1.Extent = Map1.FullExtent End Sub</P> <P>Private Sub Command2_Click() Set r = Map1.Extent r.ScaleRectangle 1.5 Map1.Extent = r End Sub</P> <P>Private Sub Form_Load() SetupLayers SetupRenderers End Sub</P> <P>Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) Set r = Map1.TrackRectangle If Not r Is Nothing Then Map1.Extent = r End Sub</P> |
|
|
|
1楼#
发布于:2005-04-19 01:49
<P><FONT size=+0><img src="http://gis.swjtu.edu.cn/emoticons/emotion-36.gif"><b>地图缩放漫游实例</b></FONT></P><P>在mo安装路径sample\VB\zoomfactor目录下</P><P>'The ZoomFactor sample illustrates scale-dependent
'MapLayers. The application makes use of the 'BeforeLayerDraw event to control which MapLayer 'objects are visible. 'The user should ensure the Zoom tool is selected 'and drag a Rectangle on the Map. When the zoom 'factor becomes smaller than 0.25, the states 'MapLayer becomes invisible, and the counties 'MapLayer become visible. This sample uses the 'USA states And counties sample data sets.</P><P>Sub DoZoom(Shift As Integer) If Shift Then ' zoom out Set r = Map1.Extent r.ScaleRectangle 1.5 Map1.Extent = r Else ' zoom in Set r = Map1.TrackRectangle If Not r Is Nothing Then Map1.Extent = r End If End Sub</P><P>Private Sub Form_Load() ' load data into the map Dim dc As New DataConnection dc.Database = ReturnDataPath("USA") If Not dc.Connect Then End Dim layer As New MapLayer Set layer.GeoDataset = dc.FindGeoDataset("States") layer.Symbol.Color = moPaleYellow Map1.Layers.Add layer</P><P> ' create another layer Set layer = New MapLayer Set layer.GeoDataset = dc.FindGeoDataset("Counties") layer.Symbol.Color = moDarkGreen Map1.Layers.Add layer End Sub</P><P>Private Sub Map1_BeforeLayerDraw(ByVal index As Integer, ByVal hDC As Stdole.OLE_HANDLE) ' if index = 1, we're drawing the bottom layer, so ' set the visible property of each mapLayer depending ' on the zoom factor If index = 1 Then Dim zoomFactor As Double ' zoomFactor is the ratio of the current extent ' to the fullExtent zoomFactor = Map1.Extent.Width / Map1.FullExtent.Width ' display the zoomFactor in label1 Label1.Caption = "Zoom Factor: " ; zoomFactor ' hide/show the mapLayers Map1.Layers("States").Visible = zoomFactor > 0.25 Map1.Layers("Counties").Visible = zoomFactor <= 0.25 End If End Sub</P><P>Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) If Toolbar1.Buttons(1).Value = 1 Then DoZoom Shift Else Map1.Pan End If End Sub</P><P>Private Sub Toolbar1_ButtonClick(ByVal Button As Button) If Button.index = 4 Then Map1.Extent = Map1.FullExtent End If End Sub</P> |
|
|
|
2楼#
发布于:2005-04-21 20:24
请教下在Annotation这个实例中,路的名称他是怎么加进去的啊?????
|
|
|
3楼#
发布于:2005-04-23 13:00
请问有没有自动网格剖分的实例?我要的是确定一个点,然后从这个点开始按一定长度向左右上下剖分单元格。谢谢
|
|
|
4楼#
发布于:2005-04-23 21:17
<img src="images/post/smile/dvbbs/em01.gif" /><img src="images/post/smile/dvbbs/em07.gif" /><img src="images/post/smile/dvbbs/em02.gif" /><img src="images/post/smile/dvbbs/em08.gif" />
|
|
|
5楼#
发布于:2005-05-30 10:16
<P><img src="images/post/smile/dvbbs/em07.gif" /><img src="images/post/smile/dvbbs/em01.gif" /></P>
|
|
|
6楼#
发布于:2005-06-21 00:27
刚开始学习,不知道什么时候才能看懂这些东西。
|
|