今天刚测试通过的,希望大家支持
参数说明:LayerName-----------tab表名,不加“.tab”,如 "china"
FeatureName------------------图元名称
sStrxy--------------------存放坐标的字符串,如:“117.145424,37.454254”
Function AddPointToLayer(LayerName,FeatureName,sStrxy)
Dim bResult,objMapx,lyr
Dim ftrNewPt,ftrAddPt
Dim flocx,flocy,tt
tt = Split(sStrxy,",",-1,1)
flocx = tt(0)
flocy = tt(1)
Set objMapx = GetMapEngine()
Set lyr = objMapx.Layers.Item(LayerName)
If CreateMapFeature(ftrNewPt) = True Then
ftrNewPt.Attach objMapX
ftrNewPt.Type = miFeatureTypeSymbol
ftrNewPt.Style.SymbolFont.Name = "Mapinfo Symbols"
ftrNewPt.Style.SymbolCharacter = 35
ftrNewPt.Style.SymbolFont.Size = 8
ftrNewPt.Style.SymbolFontColor = 255
ftrNewPt.Point.Set flocx,flocy
Set ftrAddPt = lyr.AddFeature(ftrNewPt)
ftrAddPt.Keyvalue = FeatureName
ftrAddPt.Update
End If
bResult = SetLayerProperties(lyr, True, True, True)
bResult = SetMapCenter(fLocX, fLocY)
Set objMapx = Nothing
Set lyr = Nothing
End Function