惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
D
Docker
月光博客
月光博客
MongoDB | Blog
MongoDB | Blog
Vercel News
Vercel News
美团技术团队
博客园 - 叶小钗
I
InfoQ
Jina AI
Jina AI
博客园 - 司徒正美
雷峰网
雷峰网
B
Blog
Y
Y Combinator Blog
A
About on SuperTechFans
WordPress大学
WordPress大学
酷 壳 – CoolShell
酷 壳 – CoolShell
大猫的无限游戏
大猫的无限游戏
Microsoft Security Blog
Microsoft Security Blog
Stack Overflow Blog
Stack Overflow Blog
腾讯CDC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Recent Announcements
Recent Announcements
V
V2EX
N
Netflix TechBlog - Medium

博客园 - lauer

通过配置文件添加MIME类型 NHibernate4使用Oracle.ManagedDataAccess.dll连接oracle及配置多个数据库连接 Myeclipse闪退故障 Log4j快速使用精简版 Eclipse快捷键 10个最有用的快捷键 Java compiler level does not match解决方法 ArcMap常用VBA firefox浏览器中silverlight无法输入问题 C#导入Excel遇到数字字母混合列数据丢失解决 ArcMap计算PolyLine中点VBA ArcGIS Server .NET ADF中的AJAX之深入浅出/CallbackResult详解 地图缓存与瓦片切割步骤 柱状专题图实现例子 控制图层是否显示的方法 ArcGIS Server 9.2 实现基于web浏览器的在线编辑 VB的Winsock控件GetData方法获取汉字乱码解决方法 汉字转拼音缩写(VB版) 汉字转拼音缩写(C#版) 汉字转拼音(C#版)
ArcGIS Server 开发初步 -- 自定义工具
lauer · 2011-03-12 · via 博客园 - lauer

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