gisboy
卧底
卧底
  • 注册日期2003-07-26
  • 发帖数162
  • QQ
  • 铜币900枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1933回复:2

mo中使用编辑已有图层并保存修改的方法是??

楼主#
更多 发布于:2004-07-02 13:04
mo中使用编辑已有图层并保存修改的方法是??我找了一遍,提供的实例源码中么有这一部分的内容,请做过的同志帮忙一下了。
喜欢0 评分0
Our doing are not really as important as we think. Our successes and failures didn't matter after all.
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15947
  • QQ554730525
  • 铜币25339枚
  • 威望15364点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2004-07-05 16:55
<P>论坛发过好几个编辑的例子了,再发一个吧,控件自己看了</P><P>Option Explicit</P><P>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</P><P>Private Sub Command1_Click()</P><P>'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</P><P>'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</P><P>'Load new shapefile into map
Map1.Layers.Add mlyrNew</P><P>'Notify user if everything worked
If Map1.Layers.Count = 2 Then
  MsgBox "New shapefile loaded and ready to edit."
End If</P><P>End Sub</P><P>Private Sub Form_Load()</P><P>Dim mlyr As New MapObjects2.MapLayer</P><P>'Add base layer
dc.Database = App.Path
dc.Connect
Set mlyr.GeoDataset = dc.FindGeoDataset("njspf27")
mlyr.Symbol.Color = moLightGray
Map1.Layers.Add mlyr</P><P>'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</P><P>'Initialize
recno = 0</P><P>End Sub</P><P>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</P>
举报 回复(0) 喜欢(0)     评分
nxy_918
路人甲
路人甲
  • 注册日期2003-09-15
  • 发帖数74
  • QQ
  • 铜币325枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2005-03-02 14:27
<P>请问gis兄你程序中的这一段</P><P>Set recsNew.Fields("Shape").Value = polyTracked
recsNew.Fields("ID").Value = recno
recsNew.Fields("IDSTR").Value = Format(recno, "#0")
recsNew.Fields("NAME").Value = Text2.Text</P><P>如果去掉</P><P>后面三句是否照样能保存呢?</P><P>变成</P><P>Set recsNew.Fields("Shape").Value = polyTracked
</P>
举报 回复(0) 喜欢(0)     评分
游客

返回顶部