package com.xt.hb.utils { import com.esri.ags.tasks.QueryTask; import com.esri.ags.tasks.supportClasses.Query; import mx.controls.Alert; import mx.rpc.AsyncResponder; /** * 地图工具类,主要是地图操作相关接口 */ public class GisUtils { public static var queryTask:QueryTask = new QueryTask(); public static var query:Query = new Query(); /** * */ public static function callGisServer(url:String, func:Function, condition:String, otherFields:Array = null) : void { queryTask.url=url; queryTask.useAMF = true; //queryTask.query.text=qText.text; //queryTask.query.where="STATE_NAME like '%"+qText.text+"%'"; //设置查询语句 if(null != condition && "" != condition) { query.where=condition; } else { query.where="1=1"; } //查询结果是否返回Geometry query.returnGeometry=true; query.spatialRelationship="esriSpatialRelEnvelopeIntersects"; //设置要查询的字段 var fields:Array=new Array(); fields.push("fid"); fields.push("shape"); fields.push("id"); if(null != otherFields && otherFields.length > 0) { for each(var str:String in otherFields) { fields.push(str); } } query.outFields=fields; //进行查询成功调用onResult方法,错误失败调用onFault queryTask.execute(query,new AsyncResponder(func,onLayerFault)); } //查询失败提示 public static function onLayerFault(info:Object, token:Object = null ):void { //Alert.show("获取GisServer信息出错 ! " + info.toString()); } } } class SingletonEnforcer {}