📄 cls_mapclass.pas
字号:
unit cls_MapClass;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Dialogs,
ExtCtrls, Menus, ComCtrls, StdCtrls, ImgList, OleCtrls, MapXLib_TLB, Buttons,
ADODB;
type
TMapClass=Class
private
m_Map: TMap;
public
constructor Create(Map:TMap);
function ZoomInTool: Boolean;//放大
function ZoomOutTool : Boolean;//缩小
function PanTool : Boolean; //平移
function CenterTool : Boolean; //居中显示
function SelectByPtn: Boolean;//点选
function RulerTool :Boolean; //标尺
function LabelTool : Boolean; //标注
function RadiusSelectTool: Boolean;//圆选
function RectSelectTool: Boolean;//矩形选择
function PolygonSelectTool : Boolean;//多边形选择
function CancelSelectTool:Boolean;//取消选择
function ExtendTool: Boolean;//显示所有对象
end;
Const
miRulerTool=400;
implementation
{ TMapClass }
constructor TMapClass.Create(Map: TMap);
begin
m_Map:=Map;
m_map.CreateCustomTool(miRulerTool,miToolTypePoly,miCrossCursor,emptyparam,emptyparam); //创造自定义标尺工具
end;
//*********************************************
//**** 放大
//*********************************************
function TMapClass.ZoomInTool: Boolean;
begin
try
m_Map.CurrentTool:=miZoomInTool;
Result:=True;
except
on E: Exception do
begin
ShowMessage(E.Message);
Result:=False;
end;
end;
end;
//*********************************************
//**** 缩小
//*********************************************
function TMapClass.ZoomOutTool: Boolean;
begin
try
m_Map.CurrentTool:=miZoomOutTool;
Result:=True;
except
on E: Exception do
begin
ShowMessage(E.Message);
Result:=False;
end;
end;
end;
//*********************************************
//**** 平移
//*********************************************
function TMapClass.PanTool: Boolean;
begin
try
m_Map.CurrentTool:=miPanTool;
Result:=True;
except
on E: Exception do
begin
ShowMessage(E.Message);
Result:=False;
end;
end;
end;
//*********************************************
//**** 居中显示
//*********************************************
function TMapClass.CenterTool: Boolean;
begin
try
m_Map.CurrentTool:=miCenterTool;
Result:=True;
except
on E: Exception do
begin
ShowMessage(E.Message);
Result:=False;
end;
end;
end;
//*********************************************
//**** 点选
//*********************************************
function TMapClass.SelectByPtn: Boolean;
begin
try
m_Map.CurrentTool:=miSelectTool; //miPtnSelect=300,自定义
Result:=True;
except
on E: Exception do
begin
ShowMessage(E.Message);
Result:=False;
end;
end;
end;
//*******************************************
//**** 标尺
//*******************************************
function TMapClass.RulerTool: Boolean;
begin
try
m_Map.CurrentTool:=miRulerTool; //miRulerTool=400,自定义
Result:=True;
except
on E: Exception do
begin
ShowMessage(E.Message);
Result:=False;
end;
end;
end;
//******************************************************
//**** 标注
//******************************************************
function TMapClass.LabelTool: Boolean;
begin
try
m_Map.CurrentTool:=miLabelTool;
Result:=True;
except
on E: Exception do
begin
ShowMessage(E.Message);
Result:=False;
end;
end;
end;
//******************************************************
//**** 圆形选择
//******************************************************
function TMapClass.RadiusSelectTool: Boolean;
begin
try
m_Map.CurrentTool:=miRadiusSelectTool;
Result:=True;
except
on E: Exception do
begin
ShowMessage(E.Message);
Result:=False;
end;
end;
end;
//******************************************************
//**** 矩形选择
//******************************************************
function TMapClass.RectSelectTool: Boolean;
begin
try
m_Map.CurrentTool:=miRectSelectTool;
Result:=True;
except
on E: Exception do
begin
ShowMessage(E.Message);
Result:=False;
end;
end;
end;
//******************************************************
//**** 多边形选择
//******************************************************
function TMapClass.PolygonSelectTool: Boolean;
begin
try
m_Map.CurrentTool:=miPolygonSelectTool;
Result:=True;
except
on E: Exception do
begin
ShowMessage(E.Message);
Result:=False;
end;
end;
end;
//******************************************************
//**** 取消选择
//******************************************************
function TMapClass.CancelSelectTool: Boolean;
var
i:Integer;
begin
try
for i:=1 to m_Map.Layers.Count do
begin
m_Map.Layers.Item[i].Selection.ClearSelection;
end;
m_Map.CurrentTool:=miArrowTool;
Result:=true;
except
on E: Exception do
begin
ShowMessage(E.Message);
Result:=False;
end;
end;
end;
//******************************************************
//**** 显示所有图像
//******************************************************
function TMapClass.ExtendTool: Boolean;
begin
try
m_Map.Bounds:=m_Map.Layers.Bounds;
Result:=true;
except
on E: Exception do
begin
ShowMessage(E.Message);
Result:=False;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -