web自定义放大工具(与地图进行交互)

本文介绍如何通过自定义Web工具实现地图的缩放功能。具体步骤包括:创建CustomizedWebTools类库,定义ZoomInTool类;在customizedCommands.cs文件中添加ZoomIn命令处理逻辑;在页面中注册并使用ZoomInTool。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1 新建CustomizedWebTools.cs,添加
namespace CustomizedWebTools
{
    public class ZoomInTool : MapInfo.WebControls.WebTool
    {
        public ZoomInTool()
        {
            //Command = "";
            this.ClientInteraction = ClientInteractionEnum.ClickInteraction.ToString();
            Active = false;
            //CursorImageUrl = string.Format("{0}/MapInfoWeb{1}.cur", MapInfo.WebControls.Resources._resourceFolderMain, Command);
            CursorImageUrl = "";
        }
    }
}
2 在customizedCommands.cs文件中,添加ZoomIn方法类
 [Serializable]
 public class ZoomIn : MapBaseCommand {
  /// <summary>
  /// Constructor for the command.
  /// </summary>
  /// <remarks>Sets the name of the command.</remarks>
  public ZoomIn() {
   Name = "ZoomIn";
  }

  /// <summary>
  /// Gets the map object out of the Mapfactory with a given MapAlias, zooms using two screen points, and streams the image
  /// back to client.
  /// </summary>
  /// <remarks>None</remarks>
  public override void Process() {
   MapControlModel model = MapControlModel.GetModelFromSession();
   model.SetMapSize(MapAlias, MapWidth, MapHeight);
   System.Drawing.Point[]  points = ExtractPoints(DataString);
   model.Zoom(MapAlias, points[0], points[1],  true);
   MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat);
   StreamImageToClient(ms);
  }
 }

3 在设计中添加<cc2:ZoomInTool id="ZoomInTool1".............Command="ZoomIn" ClientInteraction="RectInteraction"></cc2:ZoomInTool>(省略号的内容设置图标等自己填),在aspx表头添加
<%@ Register TagPrefix="cc2" Namespace="CustomizedWebTools" %>
4 在MapForm1.cs中的page_load中添加
 controlModel.Commands.Add(new CustomWebTools.ZoomIn());

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值