隨筆-18  評論-20  文章-0  trackbacks-0
          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 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表達如下:


          [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,只刷新地圖,不刷新頁面;
          posted on 2007-08-16 11:15 JavaPoint 閱讀(1613) 評論(0)  編輯  收藏 所屬分類: ArcGis
          主站蜘蛛池模板: 莒南县| 龙江县| 多伦县| 延长县| 惠水县| 鱼台县| 惠州市| 叶城县| 神池县| 樟树市| 道孚县| 昌江| 平阳县| 安图县| 阜城县| 铁力市| 陵水| 元谋县| 新蔡县| 启东市| 平定县| 基隆市| 贵阳市| 常熟市| 太白县| 孟州市| 碌曲县| 临清市| 阿克苏市| 额敏县| 遂昌县| 鹤峰县| 齐齐哈尔市| 昌乐县| 汝城县| 南溪县| 三台县| 家居| 元氏县| 隆林| 农安县|