tyima
路人甲
路人甲
  • 注册日期2004-07-08
  • 发帖数18
  • QQ
  • 铜币168枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1429回复:3

关于MO得三个问题,多谢。

楼主#
更多 发布于:2004-08-18 01:02
<P>1.两个图层如何匹配?</P>
<P>2.新添加的点图层为何显示不出来?</P>
<P>3.如何新建一个图层(Shp文件)?</P>
喜欢0 评分0
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2004-08-18 09:13
<P>你指的是什么匹配?</P><P>可能是因为你的空间参考不同,所以没显示</P><P>新建图层已经在论坛发过了例子,你可以翻翻看</P>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
mtf
mtf
路人甲
路人甲
  • 注册日期2004-04-21
  • 发帖数22
  • QQ
  • 铜币162枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2004-08-20 00:27
<P>注意图层的顺序,点图层可能被面图层盖住了</P>
举报 回复(0) 喜欢(0)     评分
lixaokui
路人甲
路人甲
  • 注册日期2003-12-25
  • 发帖数768
  • QQ28796446
  • 铜币27枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于: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>
西门吹血,有了鼓风机,就不用吹啦!
举报 回复(0) 喜欢(0)     评分
游客

返回顶部