gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15946
  • QQ554730525
  • 铜币25338枚
  • 威望15363点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
阅读:6117回复:18

mo中简单编辑的实现,空间设置自己看哦!

楼主#
更多 发布于:2003-07-25 17:45


Option Explicit

Dim dc As New MapObjects2.DataConnection
Dim mlyrNew As New MapObjects2.MapLayer
Dim gdsNew As MapObjects2.GeoDataset
Dim recsNew As MapObjects2.Recordset
Dim tdesc As New MapObjects2.TableDesc
Dim polyTracked As MapObjects2.Polygon
Dim strNewSfName As String
Dim recno As Long

Private Sub Command1_Click()

'Empty all layers except for base layer
Dim i As Integer
For i = 0 To Map1.Layers.Count - 2
  Map1.Layers.Remove 0
Next
Map1.Refresh
Set mlyrNew = New MapObjects2.MapLayer
Set gdsNew = Nothing
Set recsNew = Nothing
DoEvents

'Create new empty shapefile
strNewSfName = Text1.Text
Set gdsNew = dc.AddGeoDataset(strNewSfName, moPolygon, tdesc)
Set mlyrNew.GeoDataset = gdsNew
mlyrNew.Symbol.Color = moRed
Set recsNew = mlyrNew.Records

'Load new shapefile into map
Map1.Layers.Add mlyrNew

'Notify user if everything worked
If Map1.Layers.Count = 2 Then
  MsgBox "New shapefile loaded and ready to edit."
End If

End Sub

Private Sub Form_Load()

Dim mlyr As New MapObjects2.MapLayer

'Add base layer
dc.Database = App.Path
dc.Connect
Set mlyr.GeoDataset = dc.FindGeoDataset("njspf27")
mlyr.Symbol.Color = moLightGray
Map1.Layers.Add mlyr

'Create output TableDesc
tdesc.FieldCount = 3
tdesc.FieldName(0) = "ID"
tdesc.FieldType(0) = moLong
tdesc.FieldPrecision(0) = 12
tdesc.FieldName(1) = "IDSTR"
tdesc.FieldType(1) = moString
tdesc.FieldLength(1) = 10
tdesc.FieldName(2) = "NAME"
tdesc.FieldType(2) = moString
tdesc.FieldLength(2) = 20

'Initialize
recno = 0

End Sub

Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    
'Draw a new polygon...
Set polyTracked = Map1.TrackPolygon
  
'...then add the new polygon to the shapefile.
recsNew.AddNew
Set recsNew.Fields("Shape").Value = polyTracked
recsNew.Fields("ID").Value = recno
recsNew.Fields("IDSTR").Value = Format(recno, "#0")
recsNew.Fields("NAME").Value = Text2.Text
recno = recno + 1
recsNew.Update
recsNew.StopEditing
Map1.Refresh
  
End Sub




[此贴子已经被作者于2003-8-9 17:47:53编辑过]
喜欢0 评分0
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15946
  • QQ554730525
  • 铜币25338枚
  • 威望15363点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2003-08-01 12:04
大家多交流
谢谢支持,有什么问题希望大家提出,大家解决
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15946
  • QQ554730525
  • 铜币25338枚
  • 威望15363点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
2楼#
发布于:2003-08-09 17:48
改正错误!
谢谢建议
举报 回复(0) 喜欢(0)     评分
游客

返回顶部