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

1 在App_Code中添加文件CustomizedCommands.cs
   在文件中添加全图的类:注意添加引用
namespace CustomWebTools
{
 /// 


 /// 查看全图
 /// 

 [Serializable]
 public class FullExtent : MapInfo.WebControls.MapBaseCommand
 {
  /// 
  /// Constructor for this command, sets the name of the command
  /// 

  /// None
  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控件

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());

完成。


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部