我用VB,供你参考一下
有两种方式:
1、用map1.TrackingLayer.AddEvent方法
这可能是你用的方法,要设置SymbolIndex
这个SymbolIndex是你在TrackingLayer上设置的符号(Symbol)的个数
如:
map1.trackinglayer.symbolcount=3 '定个3个符号
with map1.trackinlayer.symbol(0) '定义第一个符号
.SymbolType = moFillSymbol
.color=vbRed
end with
with map1.trackinlayer.symbol(1) '定义第二个
.SymbolType = moFillSymbol
.color=vbBlack
end with
with map1.trackinlayer.symbol(2) '定义第三个
.SymbolType = moFillSymbol
.color=vbBlack
end with
dim poly as new mapobject2.polygon
set poly=map1.trackinglayer.trackpolygon
map1.TrackingLayer.AddEvent poly,1 '使用第二个符号
set poly=nothing
注意:系统默认symbolcount=1,所有symbol设为0总是不会错误。
2、使用drawshape方法,一般写在AfterTrackingLayerDraw或BeforeTrackingLayerDraw事件中.
例如:
Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As stdole.OLE_HANDLE)
Dim sym As New MapObjects2.Symbol
If Not rect Is Nothing then
sym.SymbolType = moFillSymbol
sym.Style = moDiagonalCrossFill
sym.Color = moBlue
Map1.DrawShape rect, sym
End If
End Sub
如果要用画许多个shape,可以定义两个集合,定义为单元级的局部变量:
privte ShapeCollect as new vba.collection 'Delpi中可以用TList
private SymCollect as new vba.collection
在添加一个Shape到shapecollect时,同时添加一个新的Symbol到symcollect中.
最后在AfterTrackingLayerDraw事件中
dim i as integer
for i=1 to ShapeCollect.count
Map1.DrawShape ShapeCollect(i),SymCollect(i)
next
就这么多了,你自己试一试