Q
question
Unregistered / Unconfirmed
GUEST, unregistred user!
如何在 MO (MapObjects) 中用自定颜色标记多块多边形?
具体要求看程序中的注释。
代码如:
procedure TfrmMainMap.SearchBtnClick(Sender: TObject);
var
layer : IMoMapLayer;
recs : IMoRecordset;
shp : IMoPolygon;
rect : IMoRectangle;
fields : IMoFields;
exp : string;
v : Variant;
flds : IMoFields;
fld : IMoField;
tdesc: IMoTableDesc;
I:Integer;
begin
//操作的是一块行政区划图(shp文件)
recs := IMoMapLayer(Map1.layers.item('XZQ')).Records;
recs.MoveFirst;
While not recs.EOF do begin
tdesc := IMoTableDesc(CreateOleObject('MapObjects2.TableDesc'));
tdesc := recs.TableDesc;
flds := recs.Fields;
for i := 0 to tdesc.FieldCount-1 do begin
fld := flds.Item(tdesc.FieldName);
if fld.Name = 'NAME' then begin
//需要在这里制定 Name = 'aa' 的用红色, Name ='BB' 的用白色 Name = 'CC' 的用绿色等
if fld.valueasstring = 'aa' then
//如何写?
end;
end;
recs.MoveNext;
end;
end;
end;
具体要求看程序中的注释。
代码如:
procedure TfrmMainMap.SearchBtnClick(Sender: TObject);
var
layer : IMoMapLayer;
recs : IMoRecordset;
shp : IMoPolygon;
rect : IMoRectangle;
fields : IMoFields;
exp : string;
v : Variant;
flds : IMoFields;
fld : IMoField;
tdesc: IMoTableDesc;
I:Integer;
begin
//操作的是一块行政区划图(shp文件)
recs := IMoMapLayer(Map1.layers.item('XZQ')).Records;
recs.MoveFirst;
While not recs.EOF do begin
tdesc := IMoTableDesc(CreateOleObject('MapObjects2.TableDesc'));
tdesc := recs.TableDesc;
flds := recs.Fields;
for i := 0 to tdesc.FieldCount-1 do begin
fld := flds.Item(tdesc.FieldName);
if fld.Name = 'NAME' then begin
//需要在这里制定 Name = 'aa' 的用红色, Name ='BB' 的用白色 Name = 'CC' 的用绿色等
if fld.valueasstring = 'aa' then
//如何写?
end;
end;
recs.MoveNext;
end;
end;
end;