|
阅读:1732回复:3
高手请进,谁能把下面的源代码注释写详细点,谢谢
<P>'The ZoomFactor sample illustrates scale-dependent<BR>'MapLayers. The application makes use of the<BR>'BeforeLayerDraw event to control which MapLayer<BR>'objects are visible.<BR>'The user should ensure the Zoom tool is selected<BR>'and drag a Rectangle on the Map. When the zoom<BR>'factor becomes smaller than 0.25, the states<BR>'MapLayer becomes invisible, and the counties<BR>'MapLayer become visible. This sample uses the<BR>'USA states And counties sample data sets.</P>
<P>Sub DoZoom(Shift As Integer)<BR> If Shift Then ' zoom out<BR> Set r = Map1.Extent<BR> r.ScaleRectangle 1.5<BR> Map1.Extent = r<BR> Else ' zoom in<BR> Set r = Map1.TrackRectangle<BR> If Not r Is Nothing Then Map1.Extent = r<BR> End If<BR>End Sub</P> <P>Private Sub Form_Load()<BR> ' load data into the map<BR> Dim dc As New DataConnection<BR> dc.Database = ReturnDataPath("USA")<BR> If Not dc.Connect Then End<BR> <BR> Dim layer As New MapLayer<BR> Set layer.GeoDataset = dc.FindGeoDataset("States")<BR> layer.Symbol.Color = moPaleYellow<BR> Map1.Layers.Add layer</P> <P> ' create another layer<BR> Set layer = New MapLayer<BR> Set layer.GeoDataset = dc.FindGeoDataset("Counties")<BR> layer.Symbol.Color = moDarkGreen<BR> Map1.Layers.Add layer<BR>End Sub</P> <P>Private Sub Map1_BeforeLayerDraw(ByVal index As Integer, ByVal hDC As Stdole.OLE_HANDLE)<BR> ' if index = 1, we're drawing the bottom layer, so<BR> ' set the visible property of each mapLayer depending<BR> ' on the zoom factor<BR> If index = 1 Then<BR> Dim zoomFactor As Double<BR> ' zoomFactor is the ratio of the current extent<BR> ' to the fullExtent<BR> zoomFactor = Map1.Extent.Width / Map1.FullExtent.Width<BR> <BR> ' display the zoomFactor in label1<BR> Label1.Caption = "Zoom Factor: " ; zoomFactor<BR> <BR> ' hide/show the mapLayers<BR> Map1.Layers("States").Visible = zoomFactor > 0.25<BR> Map1.Layers("Counties").Visible = zoomFactor <= 0.25<BR> End If<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 = 1 Then<BR> DoZoom Shift<BR> Else<BR> Map1.Pan<BR> End If<BR>End Sub</P> <P>Private Sub Toolbar1_ButtonClick(ByVal Button As Button)<BR> If Button.index = 4 Then<BR> Map1.Extent = Map1.FullExtent<BR> End If<BR>End Sub</P> <P><BR> </P> |
|
|
1楼#
发布于:2007-06-20 17:54
这还不够详细吗?你把不懂的再贴出来问好了~
|
|
|
|
2楼#
发布于:2007-06-27 14:07
<img src="images/post/smile/dvbbs/em01.gif" />
|
|
|
3楼#
发布于:2007-07-20 10:06
够详细了<img src="images/post/smile/dvbbs/em01.gif" />
|
|