zoukankan      html  css  js  c++  java
  • delphi mapX添加图层,在图层上画图元,并给图元添加位图

      

    //显示批量 车辆的位置信息
    
    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;

  • 相关阅读:
    c++实现执行脚本命令
    常用命令
    ssh2.cpp
    通过scp传输文件到多个主机
    启动和监控脚本
    centos 7.2 svn 安装
    SVN提交时必须填写备注信息 配置
    centos 7.2 配置mysql
    centos 7.2 配置Nginx
    js调试的时候用console.log("变量"+scrollTop+windowHeight)
  • 原文地址:https://www.cnblogs.com/xgxhellboy/p/2784091.html
Copyright © 2011-2022 走看看