config.xml文件的配置如下:

 <widget label="资源搜索"  icon="assets/images/public_impact_over.png" config="widgets/AdvancedBusiness/AdvancedBusinessWidget.xml" url="widgets/AdvancedBusiness/AdvancedBusinessWidget.swf" />

源代码目录如下:

界面效果:

大概的思路如下:跟地图搜索的思路是一样的,不过是这里唯一变化的是可以勾选多个图层来进行query查询,其实只是进行多次循环查询不同的图层而已,核心是一样的;AdvancedBusinessWidget.xml是资源搜索模块的配置文件,AdvancedBusinessWidget.mxml是widget;AdvancedBusinessWidget.xml主要是配置资源图层搜索的服务url,用来进行query查询用,这个模块的核心其实就是调用arcgis api的query类以及queryTask

AdvancedBusinessWidget.xml:

 <?xml version="1.0" ?>
<configuration label="Louisville Parcels and Police">
<layers>
<layer>
<name>危险隐患</name>
<url>http://localhost:6080/ArcGIS/rest/services/nsBusiness/MapServer/0
</url>
<expression>NAME like '%[value]%'</expression>
<textsearchlabel>按照名称搜索</textsearchlabel>
<titlefield>NAME</titlefield>
<linkfield></linkfield>
<fields all="true">
<field name="NAME" />
</fields>
<checked>true</checked>
</layer>
<layer>
<name>应急专家</name>
<url>http://localhost:6080/ArcGIS/rest/services/nsBusiness/MapServer/1
</url>
<expression>NAME like '%[value]%'</expression>
<textsearchlabel>按照名称搜索</textsearchlabel>
<titlefield>NAME</titlefield>
<linkfield></linkfield>
<fields all="true">
<field name="NAME" />
</fields>
<checked>false</checked>
</layer>
<layer>
<name>物资装备</name>
<url>http://localhost:6080/ArcGIS/rest/services/nsBusiness/MapServer/2
</url>
<expression>NAME like '%[value]%'</expression>
<textsearchlabel>按照名称搜索</textsearchlabel>
<titlefield>NAME</titlefield>
<linkfield></linkfield>
<fields all="true">
<field name="NAME" />
</fields>
<checked>false</checked>
</layer>
<layer>
<name>救援队伍</name>
<url>http://localhost:6080/ArcGIS/rest/services/nsBusiness/MapServer/3
</url>
<expression>NAME like '%[value]%'</expression>
<textsearchlabel>按照名称搜索</textsearchlabel>
<titlefield>NAME</titlefield>
<linkfield></linkfield>
<fields all="true">
<field name="NAME" />
</fields>
<checked>false</checked>
</layer>
<layer>
<name>庇护场所</name>
<url>http://localhost:6080/ArcGIS/rest/services/nsBusiness/MapServer/4
</url>
<expression>NAME like '%[value]%'</expression>
<textsearchlabel>按照名称搜索</textsearchlabel>
<titlefield>NAME</titlefield>
<linkfield></linkfield>
<fields all="true">
<field name="NAME" />
</fields>
<checked>false</checked>
</layer>
<layer>
<name>保护对象</name>
<url>http://localhost:6080/ArcGIS/rest/services/nsBusiness/MapServer/5
</url>
<expression>NAME like '%[value]%'</expression>
<textsearchlabel>按照名称搜索</textsearchlabel>
<titlefield>NAME</titlefield>
<linkfield></linkfield>
<fields all="true">
<field name="NAME" />
</fields>
<checked>false</checked>
</layer>
<!-- <layer> -->
<!-- <name>应急仓库</name> -->
<!-- <url>http://localhost:6080/ArcGIS/rest/services/nsBusiness/MapServer/6 -->
<!-- </url> -->
<!-- <expression>NAME like '%[value]%'</expression> -->
<!-- <textsearchlabel>Search by NAME</textsearchlabel> -->
<!-- <titlefield>NAME</titlefield> -->
<!-- <linkfield></linkfield> -->
<!-- <fields all="true"> -->
<!-- <field name="NAME" /> -->
<!-- </fields> -->
<!-- <checked>false</checked> -->
<!-- </layer> -->
<layer>
<name>企业</name>
<url>http://localhost:6080/ArcGIS/rest/services/nsBusiness/MapServer/7
</url>
<expression>NAME like '%[value]%'</expression>
<textsearchlabel>按照名称搜索</textsearchlabel>
<titlefield>NAME</titlefield>
<linkfield></linkfield>
<fields all="true">
<field name="NAME" />
</fields>
<checked>false</checked>
</layer>
<layer>
<name>全选</name>
<url></url>
<expression>NAME like '%[value]%'</expression>
<textsearchlabel>按照名称搜索</textsearchlabel>
<titlefield>NAME</titlefield>
<linkfield></linkfield>
<fields all="true">
<field name="NAME" />
</fields>
<checked>false</checked>
</layer>
</layers>
<zoomscale>10000</zoomscale>
</configuration> <!-- See Search widget tag reference at http://links.esri.com/searchwidget -->

AdvancedBusinessWidgett.mxml:具体实现部分,我截图部分代码好了,具体的详见flexviewer。主要是有两种方式查询,一种是框选,另一种是关键字查询;框选查询是利用在地图框选(线 面 拉框等等)获取框选的范围Geometry,然后利用当前的Geometry作为queryTask的参数,用于query查询;输入关键字查询是类似的,不过是query的参数把geometry替换为text。

框选模式参照地图搜索部分

关键字查询:

在勾选图层的基础上循环遍历查询

             private function textFilter():void{
for each(var searchLayer:Object in configSearchGraphicalArr){//configSearchGraphicalArr是勾选的图层数组 if(searchLayer.checked && searchLayer.label!="全选"){ queryFeaturesText(searchLayer); } } }

queryFeaturesText是基于关键字搜索函数:

            private function queryFeaturesText(searchLayer:Object):void
{ hideInfoWindow(); queryLayer = searchLayer.layer; if (queryLayer && !queryLayer.loaded)
{
queryLayer.addEventListener(LayerEvent.LOAD, queryLayer_loadHandler);
queryLayer.addEventListener(LayerEvent.LOAD_ERROR, queryLayer_loadErrorHandler); function queryLayer_loadHandler(event:LayerEvent):void
{
queryLayer.removeEventListener(LayerEvent.LOAD, queryLayer_loadHandler);
queryLayer.removeEventListener(LayerEvent.LOAD_ERROR, queryLayer_loadErrorHandler); queryFeaturesText(queryLayer);
} function queryLayer_loadErrorHandler(event:LayerEvent):void
{
queryLayer.removeEventListener(LayerEvent.LOAD, queryLayer_loadHandler);
queryLayer.removeEventListener(LayerEvent.LOAD_ERROR, queryLayer_loadErrorHandler); showLoadErrorMessage(event);
} return;
} queryExpr = searchLayer.expr;
queryFields = searchLayer.fields;
queryTitleField = searchLayer.titlefield;
queryLinkField = searchLayer.linkfield;
queryLinkAlias = searchLayer.linkalias; if (queryLayer && txtSearch.text)
{
var query:Query = new Query();
var expr:String = queryExpr.replace(/\[value\]/g, txtSearch.text); query.where = expr;
query.outSpatialReference = map.spatialReference; const supportsServerSideSorting:Boolean = queryLayer.layerDetails
&& queryLayer.layerDetails.version >= 10.1
&& queryLayer.layerDetails.supportsAdvancedQueries;
const orderByFields:Array = searchLayer.orderbyfields;
if (supportsServerSideSorting && orderByFields)
{
query.orderByFields = orderByFields;
} var queryOptions:Object =
{
supportsServerSideSorting: supportsServerSideSorting,
orderByFields: orderByFields,
queryFields: queryFields
}; queryLayer.queryFeatures(
query, new AsyncResponder(queryFeatures_resultHandler,
queryFeatures_faultHandler,
queryOptions)); //showMessage(loadingLabel, true);
//showStateResults(); function queryFeatures_resultHandler(featureSet:FeatureSet, queryOptions:Object):void
{
/*
var layer:FeatureLayer=FeatureLayer(map.getLayer(searchLayer.label));
layer.featureCollection=new FeatureCollection(featureSet,layer.layerDetails);
layer.refresh();*/
var obj:Object=new Object();
obj.featureSet=featureSet;
obj.layerName=searchLayer.label;
obj.featureLayer=FeatureLayer(map.getLayer(searchLayer.label));
AppEvent.dispatch(BusinessEventType.TEXT_FILTER_EVENT,obj);
} function queryFeatures_faultHandler(info:Object, queryOptions:Object):void
{
showMessage(info.toString(), false);
} }
} //AppEvent.dispatch(BusinessEventType.TEXT_FILTER_EVENT,obj);这里会触发搜索结果表格事件,把搜索的结果更新到表格来展示

textFilter_Listener是展示搜索结果函数:

            private function textFilter_Listener(event:AppEvent):void{
//Alert.show("The event is triggered!");
var featureSet:FeatureSet=event.data.featureSet as FeatureSet;
var layerName:String=event.data.layerName;//no use right now
var featureLayer:FeatureLayer=event.data.featureLayer as FeatureLayer;
var businessTable:CustomAttributeTable=featureLayerToAttributeTable[featureLayer];
businessTable.doSpatialFilter(featureSet); }
        public function doSpatialFilter(featureSet:FeatureSet):void{
this._map.removeEventListener(ExtentEvent.EXTENT_CHANGE,extentChanged_Refresh);
this._featureSet=featureSet;
if(featureSet==null){
if(this.dataGrid&&this.skin){
this.dataGrid.dataProvider=null;
this.skin.currentState="noFeaturesInCurrentExtent";
}
}else{
if(featureSet.attributes.length>0){
if(this.dataGrid&&this.skin){
this.dataGrid.columns=this.createColumnsFromPopInfo();
this.dataGrid.dataProvider=new ArrayCollection(featureSet.attributes);
this.skin.currentState="normal";
}
}else{
if(this.dataGrid&&this.skin){
this.dataGrid.dataProvider=null;
this.skin.currentState="noFeaturesInCurrentExtent";
}
}
}
}

备注:

GIS技术交流QQ群:432512093

天津政府应急系统之GIS一张图(arcgis api for flex)讲解(八)资源搜索模块的更多相关文章

  1. 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(一)GIS一张图的系统开发环境以及flexviewer框架

    系统的GIS功能实现是基于arcgis api for flex,首先附上系统的主界面图,接下来的是对主界面的模块功能详细讲解: 一.GIS环境软件安装 (1)arcgis desktop的安装,要是 ...

  2. 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(十)态势标绘模块

    config.xml文件的配置如下: <widget label="态势标绘" icon="assets/images/impact_area_over.png&q ...

  3. 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(二)鹰眼模块

    讲解GIS功能模块实现之前,先大概说一下flexviewer的核心配置文件config.xml,系统额GIS功能widget菜单布局.系统的样式.地图资源等等都是在这里配置的,这里对flexviewe ...

  4. 天津政府应急系统之GIS一张图(arcgis api for flex)解说(二)鹰眼模块

    解说GIS功能模块实现之前,先大概说一下flexviewer的核心配置文件config.xml,系统额GIS功能widget菜单布局.系统的样式.地图资源等等都是在这里配置的,这里对flexviewe ...

  5. 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(十三)台风模块

    config.xml文件的配置如下: <widget label="台风" icon="assets/images/typhoon.png" config ...

  6. 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(十一)路径导航模块

    config.xml文件的配置如下: <widget label="路径导航" icon="assets/images/lujingdaohang.png" ...

  7. 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(六)地图搜索模块

    config.xml文件的配置如下: <widget label="地图搜索" icon="assets/images/emergency_resource_ove ...

  8. 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(四)地图导航控件模块

    config.xml文件的配置如下: <widget left="10" top="50" config="widgets/Navigation ...

  9. 天津政府应急系统之GIS一张图(arcgis api for flex)讲解(三)显示地图坐标系模块

    config.xml文件的配置如下: <widget left="3" bottom="3" config="widgets/Coordinat ...

随机推荐

  1. Performance Monitor2:Peformance Counter

    Performance Counter 是量化系统状态或活动的一个数值,Windows Performance Monitor在一定时间间隔内(默认的取样间隔是15s)获取Performance Co ...

  2. SSISDB5:Parameter

    Parameter 是Package 提供给外界的接口,通过传递不同的Parameter value,能够动态控制 Package 执行不同的Task或container,产生不同的结果. 一,Par ...

  3. Undo/Redo for Qt Tree Model

    Undo/Redo for Qt Tree Model eryar@163.com Abstract. Qt contains a set of item view classes that use ...

  4. 在usercontrol里实现导航

    (Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/NewContent.xaml&qu ...

  5. [ASP.NET MVC] 利用自定义的AuthenticationFilter实现Basic认证

    很多情况下目标Action方法都要求在一个安全上下文中被执行,这里所谓的安全上下文主要指的是当前请求者是一个经过授权的用户.授权的本质就是让用户在他许可的权限范围内做他能够做的事情,授权的前提是请求者 ...

  6. MySQL存储过程及触发器

    一.存储过程 存储过程的基本格式如下: -- 声明结束符 -- 创建存储过程 DELIMITER $ -- 声明存储过程的结束符 CREATE PROCEDURE pro_test() --存储过程名 ...

  7. 总结Oracle删除表空间遇到的问题

    问题1:删除表空间期间遭遇报错 ORA-29857 问题2:删除表空间期间遭遇 ORA-02429 问题3:表空间删除完毕,主机磁盘空间不释放 问题1:删除表空间期间遭遇报错 ORA-29857 删除 ...

  8. hibernate笔记--继承映射关系的三种实现方式

    单表继承映射(一张表): 假设我们现在有三个类,关系如下: Person类有两个子类Student和Teacher,并且子类都具有自己独有的属性.这种实体关系在hibernate中可以使用单表的继承映 ...

  9. cookie相关

    参考百度百科: Cookie,有时也用其复数形式Cookies,指某些网站为了辨别用户身份.进行session跟踪而储存在用户本地终端上的数据(通常经过加密).定义于RFC2109和2965都已废弃, ...

  10. tomcat源码剖析系列

    一个简单的web服务器 一个简单的servlet容器 连接器 创建httpRequest 创建HttpResponse 容器 生命周期 日志记录器 载入器 Session管理 关闭钩子 启动tomca ...