一、安装好MapX后,选择Delphi的Component -> Import Active 菜单添加,MapInfo MapX组
件。添加完成后,在ActiveX面板上,将会出来一个TMap控件。给出几个使用mapx的范例,假设调出的是mapx自带的USA.gst电子地图。
二。一般操作工具
map1.CurrentTool:=miZoomOutTool;
Map1.CurrentTool:=miZoomInTool;//缩放工具
map1.CurrentTool:=miSelectTool;//选择工具
Map1.CurrentTool:=miPanTool;//移动工具,其他工具同理可设
三。按点查找
procedure TForm2.SearchPoint(x:single;y:single);//查找点并选中一块区域
var
pt : point;//点
fs: Features;
name:String;
begin
pt:= copoint.Create;
pt.Set_(x,y);
fs := Map1.Layers.Item['USA'].SearchAtPoint(pt,emptyParam);
if fs.Count > 0 then
begin
name := fs.Item[1].Name;
//Application.MessageBox(PChar(name),'Info',0)
StatusBar1.panels[2].Text:=name;
end;
Map1.Zoom :=1000;//1000英里
Map1.CenterX := pt.x;
Map1.CenterY := pt.Y;
Map1.Layers.Item['USA'].Selection.Replace(fs); //选中fs
end;
四,查找城市
procedure TForm2.SearchForCapital(Capital: String);
var
FoundF:FindFeature;
//在小城市层查
begin
FoundF := Map1.Layers.Item['US Minor Cities'].Find.Search(Capital, EmptyParam);
if (FoundF.FindRC mod 10)=1 then
begin
Map1.Layers.Item['US Minor Cities'].Selection.Replace(FoundF);
Map1.Zoom := 60; //60英里
Map1.CenterX := FoundF.CenterX;
Map1.CenterY := FoundF.CenterY;
end
else
Application.MessageBox('No exact match found.','Nope',0);
end;