GisUtils.as 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package com.xt.hb.utils
  2. {
  3. import com.esri.ags.tasks.QueryTask;
  4. import com.esri.ags.tasks.supportClasses.Query;
  5. import mx.controls.Alert;
  6. import mx.rpc.AsyncResponder;
  7. /**
  8. * 地图工具类,主要是地图操作相关接口
  9. */
  10. public class GisUtils
  11. {
  12. public static var queryTask:QueryTask = new QueryTask();
  13. public static var query:Query = new Query();
  14. /**
  15. *
  16. */
  17. public static function callGisServer(url:String, func:Function,
  18. condition:String, otherFields:Array = null) : void {
  19. queryTask.url=url;
  20. queryTask.useAMF = true;
  21. //queryTask.query.text=qText.text;
  22. //queryTask.query.where="STATE_NAME like '%"+qText.text+"%'";
  23. //设置查询语句
  24. if(null != condition && "" != condition) {
  25. query.where=condition;
  26. } else {
  27. query.where="1=1";
  28. }
  29. //查询结果是否返回Geometry
  30. query.returnGeometry=true;
  31. query.spatialRelationship="esriSpatialRelEnvelopeIntersects";
  32. //设置要查询的字段
  33. var fields:Array=new Array();
  34. fields.push("fid");
  35. fields.push("shape");
  36. fields.push("id");
  37. if(null != otherFields && otherFields.length > 0) {
  38. for each(var str:String in otherFields) {
  39. fields.push(str);
  40. }
  41. }
  42. query.outFields=fields;
  43. //进行查询成功调用onResult方法,错误失败调用onFault
  44. queryTask.execute(query,new AsyncResponder(func,onLayerFault));
  45. }
  46. //查询失败提示
  47. public static function onLayerFault(info:Object, token:Object = null ):void
  48. {
  49. //Alert.show("获取GisServer信息出错 ! " + info.toString());
  50. }
  51. }
  52. }
  53. class SingletonEnforcer {}