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

    ArcGIS Server 开发初步 -- 自定义工具

    原文:http://bbs.esrichina-bj.cn/ESRI/viewthread.php?tid=5590&extra=page%3D1

    ArcGIS 9.2 Server Enterprise for Windows自定义工具

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

    l命令(Command):A command is an element on a JSP page that triggers a server side action without any further interaction on the client. An example of a command in the sample application is the "zoom to full extent" button. Once the user clicks the button, a method is called on the server。不与用户通过界面交互。
    l工具(Tool):A tool has further client side interaction before calling a method on the server. An example of a tool in this application is "zoom to rectangle". Once the user clicks the button, drags a rectangle over the map indicating the area they want to zoom 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 for the tool should be implemented in this method according to the event

    二、工具在JSP页面上的tag表达如下:
    1. <ags:tool
    2. serverAction="com.esri.adf.web.faces.event.ZoomInToolAction"  
    3. clientAction="EsriMapRectangle"
    4. clientPostBack="true"
    5. />
    复制代码

    三、注册managed-bean将所写的类作为一个managed-bean注册到faces-config.xml,并用WebContext实例作为其初始化参数:
    1. <managed-bean>
    2. <managed-bean-name>ToolClass</managed-bean-name>
    3. <managed-bean-class>com.brsc.MyToolClass</managed-bean-class>
    4. <managed-bean-scope>request</managed-bean-scope>
    5. <managed-property>
    6.         <property-name>webContext</property-name>
    7.         <value>#{mapContext}</value>
    8. </managed-property>
    9. </managed-bean>
    复制代码

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

    2.  JSPTagclientAction写入客户端鼠标选择的方式:
    1. EsriMapPoint          点选
    2. EsriMapLine           线
    3. EsriMapRectangle    四边形
    4. EsriMapCircle         圆
    5. EsriMapOval           椭圆
    6. EsriMapPolyline      多线
    7. EsriMapPolygon      多边形
    8. 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)转换为 地图坐标
    一般操作如下:

    1. public void myToolMethod(MapEvent event) {
    2.    WebContext ctx = event.getWebContext();
    3.    WebGeometry screenGeom = event.getWebGeometry();
    4.    WebGeometry mapGeom = screen.toMapGeometry(ctx.getWebMap());
    5.    ...
    6. }
    复制代码


    4.  JSPTagclientPostBack
       l 设置为false,刷新地图,并且刷新页面;
       l 设置为true,只刷新地图,不刷新页面;

    对应Server端的几何形状

    futu.JPG


  • 相关阅读:
    AIX 第3章 指令记录
    AIX 第2章 指令记录
    Oracle Exadata体系笔记
    决定undo表空间的大小
    摘录:官方文档对ROWID虚拟行的定义
    ORA-01102 cannot mount database in EXCLUSIVE mode
    居民身份证号码含义
    ORA-00257错误
    微机原理之 输入输出与中断
    操作系统总结之 输入输出系统(下)
  • 原文地址:https://www.cnblogs.com/lauer0246/p/1982220.html
Copyright © 2011-2022 走看看