在线图层上画一条polyline,指定经纬度
在线图层上画一条polyline,指定经纬度。直接给定经纬度,也可将经纬度变成两个变量赋值,也可以变成数组元素,在数据库当中获取数据来计算。参照韩鹏的VB+AE的那本书完成的。
Dim pgeoftlyr As IGeoFeatureLayer
'pgeoftlyr = New GeoFeatureLayer
Set pgeoftlyr = Me.MapControl1.Map.Layer(0)
Dim pfeatureclass As IFeatureClass
Set pfeatureclass = pgeoftlyr.FeatureClass
'pgeofeatlayer = AxMapControl1.Map.Layer(0)
Dim pdataset As IDataset
Set pdataset = pfeatureclass
Dim pworkspaceedit As IWorkspaceEdit
Set pworkspaceedit = pdataset.Workspace
pworkspaceedit.StartEditOperation
Dim pfeature As IFeature
Set pfeature = pfeatureclass.CreateFeature
Dim ppoint As IPoint
Dim ppolyline As IPointCollection
Set ppolyline = New Polyline
Set ppoint = New Point
ppoint.PutCoords 131.5, 37.3
ppolyline.AddPoint ppoint
Set ppoint = New Point
ppoint.PutCoords 131.7, 37.5
ppolyline.AddPoint ppoint
Set ppoint = New Point
ppoint.PutCoords 131.8, 37.8
ppolyline.AddPoint ppoint
Set ppoint = New Point
ppoint.PutCoords 131.9, 37.9
ppolyline.AddPoint ppoint
Set pfeature.Shape = ppolyline
Dim pfields As IFields
Set pfields = pfeatureclass.Fields
Dim idx As Integer
idx = pfields.FindField("名称")
pfeature.Value(idx) = "k2k"
pfeature.Store
pworkspaceedit.StopEditing True
MapControl1.Refresh
MsgBox ("0k")
浙公网安备 33010602011771号