Delphi操作Mapx5

一、安装好MapX后,选择DelphiComponent -> 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;

 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值