AE给定经纬度加点:

今天解决了一个学生的论文问题,现帖出来。要求原图层先加一个点的图层,以下直接给定经纬度,也可将经纬度变成两个变量赋值,也可以变成数组元素,在数据库当中获取数据来计算。参照韩鹏的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
Set ppoint = New Point
'ppoint.PutCoords X, Y

ppoint.PutCoords 131.5, 37.3

Set pfeature.Shape = ppoint
Dim pfields As IFields
Set pfields = pfeature.Fields
Dim idx As Integer
idx = pfields.FindField("名称")
pfeature.Value(idx) = "k2k"
pfeature.Store
pworkspaceedit.StopEditing True
MapControl1.Refresh
MsgBox ("0k")

posted on 2009-04-20 22:30  醉翁亭下客  阅读(770)  评论(0)    收藏  举报

导航