开发环境:MapXtreme for Windows
代码:
选中目标样式设置
function systemselectedstyle(byref style)
set style=Session(SESN_COURIER).CreateMapXStyle
style.RegionColor =12632256
style.LineColor =12632256
style.RegionPattern=2
set Session(SESN_MAPPER).SelectionStyle=style
end function
点选择
sub singlepointsel(x1,y1,layername, SearchType)
dim fs
dim f
dim bresult
dim style
dim pt
session(SESN_MAPPER).Layers(layername).selection.ClearSelection
Session(SESN_MAPPER).ExportSelection=true
set pt=Session(SESN_COURIER).createmapxpoint
pt.set x1,y1
set fs=Session(SESN_MAPPER).layers(layername).Searchatpoint(pt)
bresult=systemselectedstyle(style)
if fs.count0 then
set f=fs.item(1)
Session(SESN_MAPPER).Layers(layername).selection.add f
end if
end sub
圆形选择
sub SingleCirclesel(X1,Y1,X2,Y2,Layername, SearchType)
dim fs
dim style
dim f
dim pt
dim dblDistance
dim bresult
Session(SESN_MAPPER).ExportSelection=true
bresult=systemselectedstyle(style)
set pt=Session(SESN_COURIER).createmapxpoint
pt.set x1,y1
dblDistance = Session(SESN_MAPPER).Distance(x1,y1,x2,y2)
set f=Session(SESN_MAPPER).FeatureFactory.CreateCircularRegion( 1, Pt, dblDistance)
set fs=Session(SESN_MAPPER).layers(layername).SearchWithinFeature(f,SearchType)
for each f in fs
49
Session(SESN_MAPPER).Layers(layername).selection.add f
next
end sub
矩形选择
function SingRectSel(X1,Y1,X2,Y2,Layername, SearchType)
dim fs
dim style
dim f
dim pts
dim bresult
Session(SESN_MAPPER).ExportSelection=true
bresult=systemselectedstyle(style)
bresult= ObjSelOnSingByRect(X1,Y1,X2,Y2,Layername,SearchType,fs)
Set pts = Session(SESN_COURIER).CreateMapXPoints
pts.addxy x1,y1,1
pts.addxy x2,y1,2
pts.addxy x2,y2,3
pts.addxy x1,y2,4
set f=Session(SESN_MAPPER).FeatureFactory.CreateRegion(pts,style)
set fs=Session(SESN_MAPPER).layers(layername).SearchWithinFeature(f,SearchType)
for each f in fs
Session(SESN_MAPPER).Layers(layername).selection.add f
next
end function