阅读:1430回复:3
关于MO得三个问题,多谢。
<P>1.两个图层如何匹配?</P>
<P>2.新添加的点图层为何显示不出来?</P> <P>3.如何新建一个图层(Shp文件)?</P> |
|
1楼#
发布于:2004-08-20 11:51
<P>Option Explicit
Dim moSymbol As New MapObjects2.Symbol Dim moPolygons As New Collection</P><P>Private Sub Command1_Click()</P><P> Dim gds As MapObjects2.GeoDataset Dim sName As String Dim desc As New TableDesc Dim dc As New DataConnection Dim lyr As New MapObjects2.MapLayer Dim lPoly As Long</P><P> With CommonDialog1 .Filter = "ESRI Shapefiles (*.shp)|*.shp" .DefaultExt = ".shp" .ShowSave</P><P> If Len(.FileName) = 0 Then Exit Sub ' cancel dc.Database = CurDir</P><P> If Not dc.Connect Then Exit Sub ' bad dataConnection ' remove the extension sName = Left(.FileTitle, Len(.FileTitle) - 4) End With</P><P> With desc ' define three additional fields .FieldCount = 3</P><P> 'set the field names .FieldName(0) = "Name" .FieldName(1) = "Area" .FieldName(2) = "Perimeter"</P><P> ' set the type of field .FieldType(0) = moString .FieldType(1) = moDouble .FieldType(2) = moDouble</P><P> ' set the length of a character field</P><P> .FieldLength(0) = 16</P><P> ' set the number of digits used in the field .FieldPrecision(1) = 15 .FieldPrecision(2) = 15</P><P> ' set the number of digits to the right of the decimal point .FieldScale(1) = 3 .FieldScale(2) = 3 End With</P><P> Set gds = dc.AddGeoDataset(sName, moPolygon, desc) If gds Is Nothing Then Exit Sub ' invalid file</P><P> Set lyr.GeoDataset = gds Map1.Layers.Add lyr Map1.Refresh</P><P> For lPoly = 1 To moPolygons.Count</P><P> With lyr.Records .AddNew .Fields("Shape").Value = moPolygons(lPoly) .Fields("Name").Value = "Name " ; lPoly .Fields("Area").Value = moPolygons(lPoly).Area .Fields("Perimeter").Value = moPolygons(lPoly).Perimeter .Update End With Next lyr.Records.StopEditing End Sub</P><P>Private Sub Form_Load() With moSymbol .SymbolType = moFillSymbol .Style = moSolidFill .Color = moPaleYellow End With Command1.Caption = "Save"</P><P>End Sub</P><P>Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As Stdole.OLE_HANDLE) Dim oPoly As MapObjects2.Polygon If moPolygons.Count <> 0 Then For Each oPoly In moPolygons Map1.DrawShape oPoly, moSymbol Next End If</P><P>End Sub</P><P>Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) Dim oRect As MapObjects2.Rectangle Dim oPoly As New MapObjects2.Polygon If Button = 1 Then Set oPoly = Map1.TrackPolygon</P><P> moPolygons.Add oPoly Map1.TrackingLayer.Refresh True Else Set oRect = Map1.Extent oRect.ScaleRectangle 0.5 Map1.Extent = oRect End If End Sub</P><P>创建图层</P> |
|
|
2楼#
发布于:2004-08-20 00:27
<P>注意图层的顺序,点图层可能被面图层盖住了</P>
|
|
3楼#
发布于:2004-08-18 09:13
<P>你指的是什么匹配?</P><P>可能是因为你的空间参考不同,所以没显示</P><P>新建图层已经在论坛发过了例子,你可以翻翻看</P>
|
|
|