zoukankan      html  css  js  c++  java
  • ArcGIS Server 开发初步 自定义工具

    ArcGIS 9.2 Server Enterprise for Windows自定义工具

    在Server生成的Web App中,页面的工具按钮可以分为两类:

    l命令(Command):A command is an element on a JSP page that triggers aserver side action without any further interaction on the client. Anexample of a command in the sample application is the "zoom to fullextent" button. Once the user clicks the button, a method is called onthe server。不与用户通过界面交互。
    l工具(Tool):A tool has further client sideinteraction before calling a method on the server. An example of a toolin this application is "zoom to rectangle". Once the user clicks thebutton, drags a rectangle over the map indicating the area they want tozoom to, and then a method is called on the server。与用户通过界面交互。

    自定义工具

    一、继承接口
    public Interface com.esri.adf.web.faces.event.MapToolAction{
                 void execute(MapEvent event);
    }
    lMapToolAction 接口代表由MapControl控件事件所激活的服务器端工具,系统已预设继承此接口的类:
    PanToolAction(平移),
    ZoomInToolAction(放大),
    ZoomOutToolAction(缩小)
    lMapControl创建MapEvent 事件并将其传给继承接口的工具类的 execute(MapEvent) 函数,The business logic forthe tool should be implemented in this method according to the event。

    二、工具在JSP页面上的tag表达如下:


    [Copy to clipboard]CODE:
    <ags:tool
    serverAction="com.esri.adf.web.faces.event.ZoomInToolAction"  
    clientAction="EsriMapRectangle"
    clientPostBack="true"
    />


    三、注册managed-bean将所写的类作为一个managed-bean注册到faces-config.xml,并用WebContext实例作为其初始化参数:



    [Copy to clipboard]CODE:
    <managed-bean>
    <managed-bean-name>ToolClass</managed-bean-name>
    <managed-bean-class>com.brsc.MyToolClass</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    <managed-property>
           <property-name>webContext</property-name>
           <value>#{mapContext}</value>
    </managed-property>
    </managed-bean>


    四、注释:
    1.  JSP的Tag中serverAction写入继承MapToolAction接口的类(全称),代表对于此工具服务器端要进行的操作[ execute(MapEvent event)]
    用户也可以使用任何Managed Bean的函数作为工具对应的方法,只要这个函数使用如下声明:
    public void anyMethodName(MapEvent event)
    JSP标签使用serverMethod ,如下:
    <ags:tool serverMethod="#{bean.anyMethodName}" ... />
    这样,MapControl也会将适当的MapEvent 事件传入此函数。

    2.  JSP的Tag中clientAction写入客户端鼠标选择的方式:



    [Copy to clipboard]CODE:
    EsriMapPoint          点选
    EsriMapLine           线
    EsriMapRectangle    四边形
    EsriMapCircle         圆
    EsriMapOval           椭圆
    EsriMapPolyline      多线
    EsriMapPolygon      多边形
    EsriMapPan            移动




    对应Server端的几何形状(附图)

    3.  MapEvent代表客户端进行操作产生的事件,一般会用到MapEvent的
    public WebGeometry getWebGeometry()函数来得到客户端输入的几何形状
    //Returns the WebGeometry in screen coordinates corresponding to
    //the client action performed by the user.
    来获得客户端产生的形状,这些Geomentry一般都是screen坐标,需要用toMapGeometry(WebMap)转换为 地图坐标 。
    一般操作如下:



    [Copy to clipboard]CODE:
    public void myToolMethod(MapEvent event) {
      WebContext ctx = event.getWebContext();
      WebGeometry screenGeom = event.getWebGeometry();
      WebGeometry mapGeom = screen.toMapGeometry(ctx.getWebMap());
      ...
    }



    4.  JSP的Tag中clientPostBack
      l 设置为false,刷新地图,并且刷新页面;
      l 设置为true,只刷新地图,不刷新页面;
  • 相关阅读:
    (基本知识)Redis 字符串(String)相关函数
    (基本知识)Redis 键相关命令函数
    (基本知识)Redis连接与安全
    centos7 php开发环境安装-Redis
    centos7 php开发环境安装--配置SSL(Apache为例)
    centos7 php开发环境安装-Git
    centos7 php开发环境安装-Nginx
    串口发送数据
    七大查找算法
    基于STM32原子战舰板内存管理源码详解
  • 原文地址:https://www.cnblogs.com/monica/p/1635663.html
Copyright © 2011-2022 走看看