Delphi에서 MapWinGIS를 기반으로 도면층 마크업을 추가 및 삭제하는 방법

6953 단어 Delphi
unit Form_MainU;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,MapWinGIS_TLB, DB, Grids, DBGrids, DBTables, OleCtrls, ComCtrls,
  StdCtrls ;

type
  TForm1 = class(TForm)
    Button1: TButton;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    Map1: TMap;
    Table1: TTable;
    DBGrid1: TDBGrid;
    DataSource1: TDataSource;
    OpenDialog1: TOpenDialog;
    Button2: TButton;
    StatusBar1: TStatusBar;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Map1MouseMove(ASender: TObject; Button, Shift: Smallint; x,
      y: Integer);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
    AShape:Shapefile;
    MapHanle:integer;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  self.OpenDialog1.FileName :='*.SHP';
   if self.OpenDialog1.Execute() then
   begin
     AShape:=MapWinGIS_TLB.CoShapefile.Create;
     AShape.Open(self.OpenDialog1.FileName,nil);
     MapHanle:=self.Map1.AddLayer(AShape,true);
     self.Table1.TableName :=ExtractFilePath(self.OpenDialog1.FileName)+'grid.dbf';
     self.Table1.Active:=true;
   end;
end;

procedure TForm1.Map1MouseMove(ASender: TObject; Button, Shift: Smallint;
  x, y: Integer);
var
  XX,YY:Double;
begin
  Self.Map1.PixelToProj(x,y,XX,YY);
  Self.StatusBar1.Panels[0].Text :='X='+formatFloat('#.##',XX);
  Self.StatusBar1.Panels[1].Text :='Y='+formatFloat('#.##',YY);
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  i:Integer;
  x,y:Double;
begin
  for i:=0 to AShape.NumShapes-1 do
  begin
    x:=AShape.Shape[i].Extents.xMin;
    y:=AShape.Shape[i].Extents.yMin;
    Self.Map1.AddLabel(MapHanle,'v',clBlack,x,y,MapWinGIS_TLB.hjCenter);//    
    Self.Map1.Redraw;//    
  end;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  self.Map1.ClearLabels(MapHanle);//    
  Self.Map1.Redraw;//  
end;

end.

 
MapWinGIS는 마크업을 추가하는 속도가 매우 빨라서 9만여 개의 마크업을 도면층에 추가하는데 기다리는 시간은 참을 수 있습니다. 한 6~9초 정도 걸립니다.

좋은 웹페이지 즐겨찾기