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

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

猜你喜欢

转载自blog.csdn.net/fuao/article/details/2348394