ArcEnging 修改mxd文件比例尺

在ArcGIS二次开发中,说到修改地图比例尺,最简单直观的方法肯定是直接给IMap接口的MapScale属性赋值。
但是在实际操作的时候会发现在内存中读取mxd文件,修改比例尺之后保存,所做的修改并没有生效,网上冲浪一番后找到解决办法,记录一下:
需要引入User32.dll,具体是何原理不太清楚,希望有高人指点迷津。
[System.Runtime.InteropServices.DllImport("User32.dll")]
public static extern int GetDesktopWindow(); 

private IMapDocument mapDocument = null;

private void ChangeMapScale()
{
    mapDocument.Open(@"C:\Temp\foo.mxd", null);

    IPageLayout pageLayout = mapDocument.PageLayout;
    IActiveView activeView = (IActiveView)pageLayout;
    IMap map = activeView.FocusMap;

    activeView = (IActiveView)mapDocument.PageLayout;
    activeView.Activate(GetDesktopWindow());

    map.MapScale = value;
    activeView.Refresh();

    mapDocument.Save(true, true);
}

参考网址:https://gis.stackexchange.com/questions/9943/mapscale-not-being-persisted-properly-in-mxd-when-programmatically-changed-outsi?answertab=votes#tab-top

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值