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秒钟吧。