综合

img mittee

GIS的二次开发——使用pb调用mapx控件(原创)

发表于2004/9/24 14:45:00  2149人阅读

///新建图层的函数
//wf_add_layer

oleobject aLayer,lb_dataset,LayerInfo,Flds
ole_1.object.Geoset='H:/water_pt_map.gst'
alayer=Create OleObject
alayer.ConnectToNewObject("MapX.Layer.5")
LayerInfo=Create OleObject
LayerInfo.ConnectToNewObject("MapX.LayerInfo.5")
Flds=Create OleObject
Flds.ConnectToNewObject("MapX.fields.5")

 Flds.AddStringField ("ID", 12 )
 Flds.AddStringField ("Name", 50)

//新建图层
LayerInfo.Type = 6
LayerInfo.AddParameter ("NAME", 'meteruse')
LayerInfo.AddParameter ("Fields", Flds )
LayerInfo.AddParameter ("AUTOCREATEDATASET", 1)
LayerInfo.AddParameter ("DATASETNAME", "PT_WATER")
alayer = ole_1.object.Layers.Add(LayerInfo, 1)
//设置活动图层
ole_1.object.layers.animationlayer = alayer
//

//========================
//name:wf_add_dot
//dec{3} ldc_x,ldc_y
//
//增加点的函数,分级别显示
//
//time:20040924
//
//=======================
long ll_f

//按照级别设置颜色

if il_jb = 1 then
ole_1.object.DefaultStyle .SymbolCharacter = 35
ole_1.object.DefaultStyle .SymbolFontColor = RGB(255, 0, 0)
ole_1.object.DefaultStyle .SymbolFont.Size = 12
//ole_1.object.DefaultStyle .SymbolFont="Map Symbols"
ole_1.object.DefaultStyle .textFontColor = RGB(255, 0, 0)
ole_1.object.DefaultStyle .textFont.Size = 12
ole_1.object.DefaultStyle .textFont="宋体"
 elseif il_jb = 2 then
  ole_1.object.DefaultStyle .SymbolCharacter = 36
ole_1.object.DefaultStyle .SymbolFontColor = RGB(255, 255, 0)
ole_1.object.DefaultStyle .SymbolFont.Size = 11
ole_1.object.DefaultStyle .textFontColor = RGB(255, 255, 0)
ole_1.object.DefaultStyle .textFont.Size = 11
 elseif il_jb = 3 then
ole_1.object.DefaultStyle .SymbolCharacter = 37
ole_1.object.DefaultStyle .SymbolFontColor = RGB(255, 127, 0)
ole_1.object.DefaultStyle .SymbolFont.Size = 10
ole_1.object.DefaultStyle .textFontColor = RGB(255, 127, 0)
ole_1.object.DefaultStyle .textFont.Size = 10
 end if

int i,n=1
oleobject f,f2,lb_dataset,flds,rv
oleobject aLayer
oleobject m_point
lb_dataset=Create OleObject
lb_dataset.ConnectToNewObject("MapX.dataset.5")
flds=Create OleObject
flds.ConnectToNewObject("MapX.fields.5")
rv=Create OleObject
rv.ConnectToNewObject("MapX.rowvalue.5")
alayer=Create OleObject //("mapx.layer.5")
f=Create OleObject
f2=Create OleObject
m_point =Create OleObject
alayer.ConnectToNewObject("MapX.Layer.5")
ll_f = f.ConnectToNewObject("MapX.Feature.5")
ll_f = f2.ConnectToNewObject("MapX.Feature.5")
ll_f = m_point.ConnectToNewObject("MapX.point.5")
aLayer=ole_1.object.layers.item("meteruse")
lb_dataset = aLayer.Datasets.Item("PT_WATER")
flds=lb_dataset.Fields
aLayer.LabelProperties.Dataset =lb_dataset

aLayer.LabelProperties.DataField =lb_dataset.Fields.Item("id")

aLayer.autolabel=true
aLayer.Editable=True

if is_name <>"" and not isnull(is_name) then
if il_same_f  = 1 then//已经在地图上存在的 移动坐标
 
 f = aLayer.GetFeatureByKey (is_FeatureKey)
 f.point.Set(adc_x ,adc_y)
 f.update()
 
 
else//没有存在的增加之
ole_1.object.AutoRedraw=False
m_point.Set(adc_x ,adc_y)
f = ole_1.object.featurefactory.createsymbol(m_point,ole_1.object.defaultstyle)


 aLayer.KeyField= Flds.Item(1).Name
 f.KeyValue=is_name

 
f2=aLayer.addfeature(f)
is_FeatureKey  =f2.FeatureKey
il_same_f  = 1
end if

aLayer.Refresh
ole_1.object.AutoRedraw=true
end if

//=====================================
//name :wf_delete_feature
//
//string as_featruekey
//删除地图上的一个 符号
//
//
//20040913
//===================================


oleobject aLayer
alayer=Create OleObject //("mapx.layer.5")

alayer.ConnectToNewObject("MapX.Layer.5")
aLayer=ole_1.object.layers('meteruse')

aLayer.DeleteFeature(as_featruekey)
aLayer.refresh

阅读全文
0 0

相关文章推荐

img
取 消
img