阅读:2856回复:7
请问MO中是否可以创建新的图层?
<P> 我知道MapX中是可以通过map1.layers.createlayer(),可以创建一个新的临时或永久图层,对于永久图层通过编辑后是可以以.tab等文件的形式存在的。 </P>
<P> 不知道MO中是否有?我只发现有map1.drawshape.</P> |
|
1楼#
发布于:2004-11-18 09:55
<P>可以的,下面是一个增加line层的例子</P><P>Private Sub CmdAddShape_Click()
Dim gd As MapObjects2.GeoDataset Dim dc As New MapObjects2.DataConnection Dim name As String Dim ShapeName As String Dim tDesc As New MapObjects2.TableDesc</P><P> '设置保存的shp文件名</P><P> Me.DlgAddShape.Filter = "ESRI Shapefiles(*.shp)|*.shp" Me.DlgAddShape.DefaultExt = ".shp" Me.DlgAddShape.ShowSave If Len(Me.DlgAddShape.FileName) = 0 Then Exit Sub dc.Database = CurDir If Not dc.Connect Then Exit Sub name = Left(Me.DlgAddShape.FileTitle, Len(Me.DlgAddShape.FileTitle) - 4) '编辑字段</P><P> tDesc.FieldCount = 4 tDesc.FieldName(0) = "Name" tDesc.FieldName(1) = "Length" tDesc.FieldName(2) = "Start" tDesc.FieldName(3) = "End" tDesc.FieldType(0) = moString tDesc.FieldType(1) = moDouble tDesc.FieldType(2) = moDouble tDesc.FieldType(3) = moDouble tDesc.FieldLength(0) = 16 tDesc.FieldPrecision(1) = 15 tDesc.FieldPrecision(2) = 15 tDesc.FieldPrecision(3) = 15 tDesc.FieldScale(1) = 3 tDesc.FieldScale(2) = 3 tDesc.FieldScale(3) = 3 Set gd = dc.AddGeoDataset(name, moLine, tDesc) If gd Is Nothing Then Exit Sub Dim lyr As New MapObjects2.MapLayer Set lyr.GeoDataset = gd FrmTest.MpTest.Layers.Add lyr FrmTest.MpTest.Refresh '保存数据 Dim lngCt As Long For lngCt = 1 To colLines.Count With lyr.Records .AddNew .Fields("Shape").Value = colLines(lngCt) .Fields("Name").Value = "Name" ; lngCt .Fields("Length").Value = colLines(lngCt).Length .Fields("Start").Value = colLines(lngCt) .Fields("End").Value = colLines(lngCt) .Update End With Next lngCt FrmTest.MpTest.Layers.Clear FrmTest.MpTest.Refresh End Sub </P> |
|
2楼#
发布于:2004-11-18 09:57
其中colLines是一个collection,保存绘制的线
|
|
3楼#
发布于:2004-11-19 09:40
<P>支持楼上</P><P>已经给你评了精华</P><img src="images/post/smile/dvbbs/em02.gif" />
|
|
|
4楼#
发布于:2004-11-21 09:13
<P>顶!!!!</P>
|
|
5楼#
发布于:2004-11-22 09:37
可以呀,MO帮助里有的
|
|
|
6楼#
发布于:2004-11-22 20:25
<img src="images/post/smile/dvbbs/em01.gif" />
|
|
7楼#
发布于:2004-11-23 09:41
<img src="images/post/smile/dvbbs/em01.gif" /><img src="images/post/smile/dvbbs/em02.gif" /> |
|