//显示批量 车辆的位置信息 function TFormMain.ShowCarsPosition: Boolean; var lyr: layer; //层 fts: feature; //特征 pt: MapXLib_TLB.point; //点 mstyle: style; //样式 str: string; //特征标注 speed, x, y: double; Vehiclelist: TStringList; direction, i: Integer; begin Map1.Layers.Remove(1); lyr := Map1.Layers.CreateLayer('tempAnimate', EmptyParam, 1, EmptyParam, EmptyParam); //在Map1中创建一个Layer Map1.Layers.AnimationLayer := lyr; //设为当前层 lyr.Editable := true; //可编辑 pt := copoint.Create; mstyle := costyle.Create; mstyle.SymbolType := miSymbolTypeBitmap; mstyle.SymbolBitmapSize := 18; mstyle.SymbolBitmapTransparent := True; mstyle.SymbolBitmapName := 'car.BMP'; // mstyle := map1.Layers.item['汽车服务'].AllFeatures.Item[1].Style; //此处获取在层“汽车服务”中存储的特征样式 lyr.Style := map1.Layers.item['汽车服务'].Style; //层的样式 lyr.LabelProperties.Style := map1.Layers.item['汽车服务'].LabelProperties.Style; //标签样式 Vehiclelist := TStringList.Create; Vehiclelist := SelectedVehiclelist; for i := 0 to Vehiclelist.count - 1 do begin if DM.ClientDataSet.Locate('VehicleOID', Vehiclelist.Strings[i], []) then begin x := DM.ClientDataSet.FieldByName('LONGITUDE').AsFloat; y := DM.ClientDataSet.FieldByName('LATITUDE').AsFloat; str := DM.ClientDataSet.FieldByName('Name').AsString; direction := DM.ClientDataSet.FieldByName('direction').AsInteger; speed := DM.ClientDataSet.FieldByName('speed').AsFloat; end; pt.Set_(x, y); fts := map1.FeatureFactory.CreateSymbol(pt, mstyle); //创建特征 fts.KeyValue := str; //标注 lyr.AddFeature(fts, emptyparam); //将特征添加到层 end; lyr.AutoLabel := true; //自动标注 lyr.Visible := true; //可见 lyr.ZoomMin := 0; //缩放范围 lyr.ZoomMax := 80; Map1.CenterX := x; Map1.CenterY := y; end;
mstyle.SymbolType := miSymbolTypeBitmap;
mstyle.SymbolBitmapSize := 18;
mstyle.SymbolBitmapTransparent := True;
mstyle.SymbolBitmapName := 'car.BMP';
// mstyle := map1.Layers.item['汽车服务'].AllFeatures.Item[1].Style; //此处获取在层“汽车服务”中存储的特征样式
lyr.Style := map1.Layers.item['汽车服务'].Style; //层的样式
lyr.LabelProperties.Style := map1.Layers.item['汽车服务'].LabelProperties.Style; //标签样式
Vehiclelist := TStringList.Create;
Vehiclelist := SelectedVehiclelist;
for i := 0 to Vehiclelist.count - 1 do
begin
if DM.ClientDataSet.Locate('VehicleOID', Vehiclelist.Strings[i], []) then
begin
x := DM.ClientDataSet.FieldByName('LONGITUDE').AsFloat;
y := DM.ClientDataSet.FieldByName('LATITUDE').AsFloat;
str := DM.ClientDataSet.FieldByName('Name').AsString;
direction := DM.ClientDataSet.FieldByName('direction').AsInteger;
speed := DM.ClientDataSet.FieldByName('speed').AsFloat;
end;
pt.Set_(x, y);
fts := map1.FeatureFactory.CreateSymbol(pt, mstyle); //创建特征
fts.KeyValue := str; //标注
lyr.AddFeature(fts, emptyparam); //将特征添加到层
end;
lyr.AutoLabel := true; //自动标注
lyr.Visible := true; //可见
lyr.ZoomMin := 0; //缩放范围
lyr.ZoomMax := 80;
Map1.CenterX := x;
Map1.CenterY := y;
end;