⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cls_layercontrol.~pas

📁 用Delhpi和mapx开发的警务管理系统
💻 ~PAS
📖 第 1 页 / 共 3 页
字号:
        TempLayerInfo.AddParameter('NAME',Format('%s',[pTempMapInfo^.SpaceTableName]));
        m_Map.Layers.Add(TempLayerInfo,EmptyParam);
        TempLayerInfo:=nil;
        BindLayerObject := CoBindLayer.Create;
        bindLayerObject.LayerName := pTempMapInfo^.SpaceTableName;
        BindLayerObject.LayerType := miBindLayerTypeNormal;
        strSqlString:='select * from ' + pTempMapInfo^.TableName;
        adoQue:=systemDM.Glb_BasicDataOperate.adoGetAdoQuery(strSqlString);
        m_Map.DataSets.Add(miDataSetADO,adoQue.Recordset,
        pTempMapInfo^.SpaceTableName,'FEATUREID',EmptyParam,BindLayerObject,EmptyParam,EmptyParam);
        if pTempMapInfo^.SpaceTableName='DOORPLATE_S' then
        begin
          //常驻人口数据集
          strSqlString:='select * from PermPopuAddCount';
          adoQue:=systemDM.Glb_BasicDataOperate.adoGetAdoQuery(strSqlString);
          m_Map.DataSets.Add(miDataSetADO,adoQue.Recordset,
          'PEOPLEDOORPLATEDATASET','FEATUREID',EmptyParam,BindLayerObject,EmptyParam,EmptyParam);
          //暂住人口数据集
          strSqlString:='select * from StayPopuAddCount';
          adoQue:=systemDM.Glb_BasicDataOperate.adoGetAdoQuery(strSqlString);
          m_Map.DataSets.Add(miDataSetADO,adoQue.Recordset,
          'STAYPEOPLEDOORPLATEDATASET','FEATUREID',EmptyParam,BindLayerObject,EmptyParam,EmptyParam);
        end;
        if pTempMapInfo^.SpaceTableName='POLICEHOUSE_S' then
        begin
          //单位数据集
          strSqlString:='select * from Companycount';
          adoQue:=systemDM.Glb_BasicDataOperate.adoGetAdoQuery(strSqlString);
          m_Map.DataSets.Add(miDataSetADO,adoQue.Recordset,
          'CompanyDataSet','FEATUREID',EmptyParam,BindLayerObject,EmptyParam,EmptyParam);
          //发案纪录数据集
          strSqlString:='select * from CaseRecordcount';
          adoQue:=systemDM.Glb_BasicDataOperate.adoGetAdoQuery(strSqlString);
          m_Map.DataSets.Add(miDataSetADO,adoQue.Recordset,
          'CaseRecordDataSet','FEATUREID',EmptyParam,BindLayerObject,EmptyParam,EmptyParam);
          //工作对象数据集
          strSqlString:='select * from WorkObjectcount';
          adoQue:=systemDM.Glb_BasicDataOperate.adoGetAdoQuery(strSqlString);
          m_Map.DataSets.Add(miDataSetADO,adoQue.Recordset,
          'WorkObjectDataSet','FEATUREID',EmptyParam,BindLayerObject,EmptyParam,EmptyParam);
        end;
        //标注
        BindLayerObject:=NIL;
        if pTempMapInfo^.LabelField <> '' then
        begin
          m_Map.Layers[pTempMapInfo^.SpaceTableName].LabelProperties.Dataset:=
          m_Map.DataSets.Item[pTempMapInfo^.SpaceTableName];
          m_Map.Layers[pTempMapInfo^.SpaceTableName].LabelProperties.DataField:=
          m_Map.DataSets.Item[pTempMapInfo^.SpaceTableName].Fields.Item[pTempMapInfo^.LabelField];
        end;

      end;
    end;
    m_Map.Bounds := m_Map.Layers.Item['DOORPLATE_S'] .Bounds;

    m_Map.NumericCoordSys := m_Map.DisplayCoordSys;
    for iLoop:= 1 to m_Map.Layers.Count do
    begin
      m_Map.Layers.Item[iLoop].Selectable:=false;
    end;
  except on E: Exception do
  begin
    Result := False;
    ShowMessage(E.Message);
  end;
  end;
  //m_Map.Geoset:=tempPath + 'POLICE.gst';
end;

//******************************************
//          一个库中中的图层
//   成功:True 失败:False
//******************************************
function TMapControl.LoadOneDataBaseLayer(iIndex:integer;iSelectable:integer): Boolean;
var
  TempLayerInfo: LayerInfo;
  pTempMapInfo: pMapInfo;
  kLoop,iLoop: Integer;
  tempMap:TMap;
  tempPath:string;
  BindLayerObject: CMapXBindLayer;
  strSqlString:STRING;
  adoQue:TADOQuery;
begin
  tempPath:=ExtractFilePath(Application.ExeName) + 'Map\';
  try
    if iIndex=1 then
      cDataOperate:=systemDM.Glb_BasicDataOperate;
    if iSelectable= 0 then
      tempMap:= m_GuideMap
    else
      tempMap:=m_Map;
    for kLoop:=0 to m_tvLayerControl.Items.Count -1 do
   begin
      pTempMapInfo:=m_tvLayerControl.Items[kLoop].Data;
      if ((pTempMapInfo.TableName<>'') and (pTempMapInfo.Visible=1) and (pTempMapInfo^.TableName<>'DOORPLATE')
      and (pTempMapInfo^.TableName<>'CASERECORD') and(pTempMapInfo^.TableName<>'POLICEHOUSE') and (iSelectable=0)) then
      begin
        pTempMapInfo.Visible:=1;
      //Oci连接数据库
        TempLayerInfo:=CoLayerInfo.Create;
        TempLayerInfo.Type_ := miLayerInfoTypeTab;
        TempLayerInfo.AddParameter('FileSpec',tempPath + pTempMapInfo^.SpaceTableName + '.Tab');
        TempLayerInfo.AddParameter('NAME',Format('%s',[pTempMapInfo^.SpaceTableName]));
        tempMap.Layers.Add(TempLayerInfo,EmptyParam);
        TempLayerInfo:=nil;
        BindLayerObject := CoBindLayer.Create;
        bindLayerObject.LayerName := pTempMapInfo^.SpaceTableName;
        BindLayerObject.LayerType := miBindLayerTypeNormal;

        strSqlString:='select * from ' + pTempMapInfo^.TableName;
        adoQue:=systemDM.Glb_BasicDataOperate.adoGetAdoQuery(strSqlString);
        tempMap.DataSets.Add(miDataSetADO,adoQue.Recordset,
        pTempMapInfo^.SpaceTableName,'FEATUREID',EmptyParam,BindLayerObject,EmptyParam,EmptyParam);
        //m_Map.DataSets.Add(miDataSetLayer,m_Map.Layers.Item[pTempMapInfo^.SpaceTableName],
        //pTempMapInfo^.SpaceTableName,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam);
          //标注
          BindLayerObject:=NIL;
        //tempMap.DataSets.Add(miDataSetLayer,m_Map.Layers.Item[pTempMapInfo^.SpaceTableName],
          //pTempMapInfo^.SpaceTableName,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam);
        //标注
        if pTempMapInfo^.LabelField <> '' then
        begin
          tempMap.Layers[pTempMapInfo^.SpaceTableName].LabelProperties.Dataset:=
          tempMap.DataSets.Item[pTempMapInfo^.SpaceTableName];
          tempMap.Layers[pTempMapInfo^.SpaceTableName].LabelProperties.DataField:=
          tempMap.DataSets.Item[pTempMapInfo^.SpaceTableName].Fields.Item[pTempMapInfo^.LabelField];
          //tempMap.Layers[pTempMapInfo^.SpaceTableName].AutoLabel := True;
        end;
      end;
    end;
    tempMap.Bounds := tempMap.Layers.Item['STREET_S'] .Bounds;
    tempMap.NumericCoordSys := tempMap.DisplayCoordSys;
    if iSelectable=0 then
      for kLoop:= 1 to tempMap.Layers.Count do
        tempMap.Layers.Item[kLoop].Selectable:=false
    else if iSelectable=1 then
    begin
      for iLoop:=0 to  m_tvLayerControl.Items[iIndex].Count -1 do
      begin
        pTempMapInfo:=m_tvLayerControl.Items[iIndex].Item[iLoop].Data;
        tempMap.Layers.Item[pTempMapInfo.SpaceTableName].Selectable:=true;
      end;
    end;
  except on E: Exception do
  begin
    Result := False;
    ShowMessage(E.Message);
  end;
  end;
end;


//******************************************
//     加载一个图层
//******************************************
function TMapControl.LoadOneLayer():boolean;
var
  TempLayerInfo: LayerInfo;
  pTempMapInfo: pMapInfo;
  iLoop,jLoop: Integer;
  tempPath:string;
  BindLayerObject: CMapXBindLayer;
  strSqlString:STRING;
  adoQue:TADOQuery;
begin
  tempPath:=ExtractFilePath(Application.ExeName) + 'Map\';
  pTempMapInfo:=m_tvLayerControl.Selected.Data;
  if pTempMapInfo.ParentID= 1 then
    cDataOperate:=systemDM.Glb_BasicDataOperate;
  if (pTempMapInfo.TableName<>'') then
  begin
  //Oci连接数据库
    TempLayerInfo:=CoLayerInfo.Create;
    TempLayerInfo.Type_ := miLayerInfoTypeTab;
    TempLayerInfo.AddParameter('FileSpec',tempPath + pTempMapInfo^.SpaceTableName + '.Tab');
    TempLayerInfo.AddParameter('NAME',Format('%s',[pTempMapInfo^.SpaceTableName]));
    m_Map.Layers.Add(TempLayerInfo,EmptyParam);
    TempLayerInfo:=nil;
    BindLayerObject := CoBindLayer.Create;
    bindLayerObject.LayerName := pTempMapInfo^.SpaceTableName;
    BindLayerObject.LayerType := miBindLayerTypeNormal;

    strSqlString:='select * from ' + pTempMapInfo^.TableName;
    adoQue:=systemDM.Glb_BasicDataOperate.adoGetAdoQuery(strSqlString);
    m_Map.DataSets.Add(miDataSetADO,adoQue.Recordset,
    pTempMapInfo^.SpaceTableName,'FEATUREID',EmptyParam,BindLayerObject,EmptyParam,EmptyParam);
    //m_Map.DataSets.Add(miDataSetLayer,m_Map.Layers.Item[pTempMapInfo^.SpaceTableName],
    //pTempMapInfo^.SpaceTableName,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam);
    //标注
    BindLayerObject:=NIL;
    //m_Map.DataSets.Add(miDataSetLayer,m_Map.Layers.Item[pTempMapInfo^.SpaceTableName],
      //pTempMapInfo^.SpaceTableName,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam);
    //标注
    if pTempMapInfo^.LabelField <> '' then
    begin
      m_Map.Layers[pTempMapInfo^.SpaceTableName].LabelProperties.Dataset:=
      m_Map.DataSets.Item[pTempMapInfo^.SpaceTableName];
      m_Map.Layers[pTempMapInfo^.SpaceTableName].LabelProperties.DataField:=
      m_Map.DataSets.Item[pTempMapInfo^.SpaceTableName].Fields.Item[pTempMapInfo^.LabelField];
      //m_Map.Layers[pTempMapInfo^.SpaceTableName].AutoLabel := True;
    end;
  end;
end;
//******************************************
//    设置土层是否能被选择
//******************************************
function TMapControl.SetLayerSelectable(LayerName: String; Value: Boolean): Boolean;
var
 iLoop : Integer;
begin
  try
    if LayerName<>'' then
      m_Map.Layers.Item[LayerName].Selectable := Value;
    for iLoop:=1 to m_Map.Layers.Count do
    begin
      if m_Map.Layers.Item[iLoop].Name<>LayerName then
        m_Map.Layers.Item[iLoop].Selectable:=false;
    end;
    Result := True;
  except on E: Exception do
  begin
    Result := False;
    ShowMessage(E.Message);
  end;
  end;
end;

{//*****************************************************
//****    设置所有层的可选性
//*****************************************************
function TMapControl.bSetAllLayerSelectable(bSelectable: Boolean): Boolean;
var
  i:Integer;
begin
  try
    for i:=1 to m_Map.Layers.Count do
    begin
      m_Map.Layers.Item[i].Selectable:=bSelectable;
    end;
    Result:=True;
  except on E: Exception do
  begin
    Result:=False;
    ShowMessage(E.Message);
  end;
  end;
end;}

//******************************************
//   图层控制树的MouseUp事件
//******************************************
procedure TMapControl.TreeMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  pMaInfo,pSonMapInfo: pMapInfo;
  HitTests: THitTests;
  iLoop,jLoop: Integer;
  sSpaceName:string;
begin
  HitTests:=m_tvLayerControl.GetHitTestInfoAt(X,Y);
  if htOnLabel in HitTests then
  begin
    pMaInfo:=m_tvLayerControl.Selected.Data;
    if (pMaInfo.ParentID<>0)  then
    begin
      if (pMaInfo^.Visible=1) then
      begin
        sSpaceName:=pMaInfo^.SpaceTableName;
        SetLayerSelectable(sSpaceName,True);
      end;
      //m_lvResult.Items.Clear;
      //m_lvResult.Columns.Clear;
    end;
  end;
  if htOnStateIcon in HitTests then
  begin
    pMaInfo:=m_tvLayerControl.Selected.Data;
    if (pMaInfo.ParentID<>0)  then
    begin
      if m_tvLayerControl.Selected.StateIndex=15 then
      begin
        m_tvLayerControl.Selected.StateIndex:=1;
        pMaInfo^.Visible:=0;
        m_Map.Layers.Item[pMaInfo^.SpaceTableName].Visible:=false;
      end
      else if m_tvLayerControl.Selected.StateIndex=1 then
      begin
        m_tvLayerControl.Selected.StateIndex:=15;
        pMaInfo^.Visible:=1;
        m_Map.Layers.Item[pMaInfo^.SpaceTableName].Visible:=true;
      end;
    end;
  end;
end;


//******************************************
//   导航树的MouseUp事件
//******************************************
procedure TMapControl.GuidTreeMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  pPolInfo: pPoliceInfo;
  HitTests: THitTests;
  iLoop: Integer;
  iFeatureId:integer;
  temp_ftrs:CMapXFeatures;
  strSql:string;
begin
  HitTests:=m_tvGuidTree.GetHitTestInfoAt(X,Y);
  if htOnLabel in HitTests then
  begin
    pPolInfo:=m_tvGuidTree.Selected.Data;
    if pPolInfo.FEATUREID<>0 then
    begin
      strSql:='FEATUREID=' + inttostr(pPolInfo^.FEATUREID);
      temp_ftrs:=m_Map.Layers['POLICEHOUSE_S'].search(strSql,EmptyParam);
      m_Map.CenterX:=temp_ftrs.Item[1].CenterX;
      m_Map.CenterY:=temp_ftrs.Item[1].CenterY;
      m_Map.Layers['POLICEHOUSE_S'].Selection.Replace(temp_ftrs);
    end;
  end;
end;
{//******************************************
//   设置图层可见性
//   成功:True 失败:False
//******************************************
function TMapControl.SetLayerVisible(LayerName: String;
  Value: Boolean): Boolean;
begin
  try
       if LayerName<>'' then
            m_Map.Layers.Item[LayerName].Visible := Value;
       Result := True;
  except
       on E: Exception do
            begin
            ShowMessage(E.Message);
            Result := False;
            end;
  end;
end;}


//***************************************//
//           显示关联资源Click事件       //
//***************************************//

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -