web下自定义看全图工具(不与地图交互)

1 在App_Code中添加文件CustomizedCommands.cs
   在文件中添加全图的类:注意添加引用
namespace CustomWebTools
{
 /// <summary>
 /// 查看全图
 /// </summary>
 [Serializable]
 public class FullExtent : MapInfo.WebControls.MapBaseCommand
 {
  /// <summary>
  /// Constructor for this command, sets the name of the command
  /// </summary>
  /// <remarks>None</remarks>
  public FullExtent()
  {
            Name = "FullExtent";
  }

 

        public override void  Process()
        {
            MapControlModel model = MapControlModel.GetModelFromSession();
            if (MapAlias == null) return;
            model.SetMapSize(MapAlias, MapWidth, MapHeight);
            
            MapInfo.Mapping.Map map = model.GetMapObj(MapAlias);
            if (map == null) return;
            map.Bounds = map.Layers.Bounds;

            MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat);
            StreamImageToClient(ms);
        }
    }
}

2 新建JScript.js文件
  添加方法:
//看全图
function fullExtent1(){
    var url = "MapController.ashx?Command=FullExtent&Ran=" + Math.random();
    var mapImage = document.getElementById("MapControl1_Image");                  
    if (mapImage.mapAlias) 
     url +=  "&MapAlias=" + mapImage.mapAlias;
 
 url+="&Width="+mapImage.width+"&Height="+mapImage.height+"&ExportFormat="+mapImage.exportFormat;

    mapImage.src =url;
}
3 在设计中添加HTML控件
<img src="images/fullExtent.gif" id="fullExtent" οnclick="fullExtent()" alt="点击查看全图"/>

4 在MapForm1.cs中添加
using CustomWebTools;

在page_load中添加
 MapInfo.WebControls.MapControlModel controlModel = MapControlModel.SetDefaultModelInSession();

            // add custom commands to control model
            controlModel.Commands.Add(new CustomWebTools.FullExtent());

完成。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值