delphi中 mapx鹰眼图的实现

道理很简单,就是用两个mapx,一个显示大图,一个显示小图,废话少说,直接上代码

//声明两个全局变量

var  

layer: CMapXLayer; //鹰眼图中,用于显示显示范围的那个图层,下面详细解释

ftr: CMapXFeature;  //鹰眼框

//窗体创建时,添加鹰眼框图层

procedure TForm1.FormCreate(Sender: TObject);
begin
  layer := map2.Layers.CreateLayer('rectlayer', EmptyParam, EmptyParam, EmptyParam, EmptyParam);
end;

//大图显示范围变化时,鹰眼图根据大图的情况来显示鹰眼框的大小

procedure TForm1.map1MapViewChanged(Sender: TObject);
var
  tmpFea: CMapXFeature;
  tmpPnts: CMapXPoints;
  tmpStyle: CMapXStyle;
begin

  //绘制鹰眼框
  if layer.AllFeatures.Count = 0 then begin
    tmpStyle := CoStyle.Create;
    tmpStyle.RegionBorderColor := clRed;
    tmpStyle.RegionPattern := miPatternNoFill;
    tmpStyle.RegionBackColor := clRed;
    tmpStyle.RegionBorderWidth := 1;
    tmpFea := map2.FeatureFactory.CreateRegion(map1.Bounds, tmpStyle);
    ftr := layer.AddFeature(tmpFea, EmptyParam);
  end else
  begin
    with ftr.Parts.Item[1] do begin
      RemoveAll;
      AddXY(map1.Bounds.XMin, map1.Bounds.YMin, EmptyParam);
      AddXY(map1.Bounds.XMax, map1.Bounds.YMin, EmptyParam);
      AddXY(map1.Bounds.XMax, map1.Bounds.YMax, EmptyParam);
      AddXY(map1.Bounds.XMin, map1.Bounds.YMax, EmptyParam);
      ftr.Update(ftr, EmptyParam);
    end;
  end;
  //mp2.Zoom := mp1.Zoom;
end;

//鹰眼图坐标变化,大图跟随变化

procedure TForm1.map2MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var MapX, MapY: Double;
    x1, y1: Single;
begin
  x1 := x + 0.0;
  y1 := y + 0.0;
  map2.ConvertCoord(x1, y1, MapX, MapY, miScreenToMap);  ;
  map1.CenterX := MapX;
  map1.CenterY := MapY;
end;


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值