• 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;

  • 相关阅读:
    Core2.0知识整理
    bootbox.js官方文档
    MongoDB分片详解
    MongoDB高可用集群+MMS集群监控搭建
    使用 AcceptTcpClientAsync 进行 异步 操作
    Windows证书操作
    SQL Server查询所有的表名、字段名、注释
    【转载】ASP.NET Core Web 支付功能接入 微信-扫码支付篇
    【转载】ASP.NET Core Web 支付功能接入 支付宝-电脑网页支付篇
    C#网络编程系列文章
  • 原文地址:https://www.cnblogs.com/xgxhellboy/p/2784091.html
Copyright © 2020-2023  润新知