<?xml version="1.0" encoding="utf-8"?> <!-- //////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2010 ESRI // // All rights reserved under the copyright laws of the United States. // You may freely redistribute and use this software, with or // without modification, provided you include the original copyright // and use restrictions. See use restrictions in the file: // <install location>/License.txt // //////////////////////////////////////////////////////////////////////////////// --> <viewer:BaseWidget xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:viewer="com.esri.viewer.*" widgetConfigLoaded="init()"> <fx:Script> <![CDATA[ import com.esri.ags.FeatureSet; import com.esri.ags.events.LayerEvent; import com.esri.ags.layers.FeatureLayer; import com.esri.ags.tasks.QueryTask; import com.esri.ags.tasks.supportClasses.Query; import com.esri.viewer.components.HTMLPopup; import flashx.textLayout.edit.SelectionFormat; import flashx.textLayout.events.SelectionEvent; import mx.collections.ArrayCollection; import mx.collections.SortField; import mx.controls.Alert; import mx.rpc.AsyncResponder; import mx.rpc.events.FaultEvent; private var content:String; private var contentStatus:String; private var btnLabel:String private var txtareaWidth:Number; private var txtareaHeight:Number; private var sSheltersClosedMessage:String; private var sSheltersOpenMessage:String; private var fLayer:FeatureLayer; private var statusQuery:QueryTask; private function init():void { if (configXML) { content = configXML.content || "..."; btnLabel = configXML.btnlabel || getDefaultString("okLabel"); txtareaWidth = configXML.width || 500; txtareaHeight = configXML.height || 500; sSheltersClosedMessage = configXML.sheltersclosedmessage; sSheltersOpenMessage = configXML.sheltersopenmessage; fLayer = new FeatureLayer(configXML.sheltersurl); fLayer.useAMF = false; var qry:Query = new Query(); qry.where = "OPEN = 1"; // fLayer.queryFeatures(qry, new AsyncResponder(onResult, onFault)); // Status part statusQuery = new QueryTask("http://gis.co.suffolk.ny.us/ArcGIS/rest/services/EmergencyShelters/MapServer/1"); statusQuery.useAMF = false; var qryStatus:Query = new Query(); qryStatus.where = "STATUS = 1"; qryStatus.returnGeometry = false; qryStatus.outFields = ["*"]; statusQuery.execute(qryStatus, new AsyncResponder(onResultStatus, onFault)); } private function onResultStatus(fSet:FeatureSet, token:Object=null):void { trace("Result"); if(fSet.features.length > 0) { contentStatus = "HERE1"; HTMLPopup.show(contentStatus, btnLabel, txtareaWidth, txtareaHeight); } else { contentStatus = "HERE"; HTMLPopup.show(contentStatus, btnLabel, txtareaWidth, txtareaHeight); } } private function onResult(fSet:FeatureSet, token:Object=null):void { trace("Result"); if(fSet.features.length > 0) { content = content.replace("[SHELTERMESSAGETOKEN]", sSheltersOpenMessage); var arr:Array = new Array(); for(var i:int=0; i<fSet.features.length; i++) { arr.push(fSet.attributes.NAME); } arr.sort(); var tmp:String = ""; for(i=0; i<arr.length; i++) { tmp += arr + "<br>"; } tmp = tmp += "<br>"; content = content.replace("[OPENSHELTERSTOKEN]", tmp); var bkgrndColor:String = "0x00FF00"; HTMLPopup.show(content, btnLabel, txtareaWidth, txtareaHeight); } else { content = content.replace("[SHELTERMESSAGETOKEN]", sSheltersClosedMessage); HTMLPopup.show(content, btnLabel, txtareaWidth, txtareaHeight); } } private function onFault(info:Object, token:Object = null):void { trace("Fault"); } } ]]> </fx:Script> </viewer:BaseWidget>
Extent: XMin: NaN YMin: NaN XMax: NaN YMax: NaN Spatial Reference: 2263
qry.where = "OPEN = 1";
<?xml version="1.0" encoding="utf-8"?> <!-- //////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2010 ESRI // // All rights reserved under the copyright laws of the United States. // You may freely redistribute and use this software, with or // without modification, provided you include the original copyright // and use restrictions. See use restrictions in the file: // <install location>/License.txt // //////////////////////////////////////////////////////////////////////////////// --> <viewer:BaseWidget xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:viewer="com.esri.viewer.*" widgetConfigLoaded="init()"> <fx:Script> <![CDATA[ import com.esri.ags.FeatureSet; import com.esri.ags.events.LayerEvent; import com.esri.ags.layers.FeatureLayer; import com.esri.ags.tasks.supportClasses.Query; import com.esri.viewer.components.HTMLPopup; import flashx.textLayout.edit.SelectionFormat; import flashx.textLayout.events.SelectionEvent; import mx.collections.ArrayCollection; import mx.collections.SortField; import mx.controls.Alert; import mx.rpc.AsyncResponder; import mx.rpc.events.FaultEvent; private var content:String; private var contentStatus:String; private var btnLabel:String private var txtareaWidth:Number; private var txtareaHeight:Number; private var sSheltersClosedMessage:String; private var sSheltersOpenMessage:String; private var fLayer:FeatureLayer private var statusLayer:FeatureLayer private function init():void { if (configXML) { content = configXML.content || "..."; btnLabel = configXML.btnlabel || getDefaultString("okLabel"); txtareaWidth = configXML.width || 500; txtareaHeight = configXML.height || 500; sSheltersClosedMessage = configXML.sheltersclosedmessage; sSheltersOpenMessage = configXML.sheltersopenmessage; fLayer = new FeatureLayer(configXML.sheltersurl); fLayer.useAMF = false; var qry:Query = new Query(); qry.where = "OPEN = 1"; // fLayer.queryFeatures(qry, new AsyncResponder(onResult, onFault)); // Status part statusLayer = new FeatureLayer("http://gis.co.suffolk.ny.us/ArcGIS/rest/services/EmergencyShelters/MapServer/1"); fLayer.useAMF = false; statusLayer.addEventListener(LayerEvent.LOAD, execQuery); } private function execQuery(evt:Event):void { var qryStatus:Query = new Query(); qryStatus.where = "STATUS = 1"; statusLayer.queryFeatures(qryStatus, new AsyncResponder(onResultStatus, onFault)); } private function onResultStatus(fSet:FeatureSet, token:Object=null):void { trace("Result"); if(fSet.features.length > 0) { contentStatus = "HERE1"; HTMLPopup.show(contentStatus, btnLabel, txtareaWidth, txtareaHeight); } else { contentStatus = "HERE"; HTMLPopup.show(contentStatus, btnLabel, txtareaWidth, txtareaHeight); } } private function onResult(fSet:FeatureSet, token:Object=null):void { trace("Result"); if(fSet.features.length > 0) { content = content.replace("[SHELTERMESSAGETOKEN]", sSheltersOpenMessage); var arr:Array = new Array(); for(var i:int=0; i<fSet.features.length; i++) { arr.push(fSet.attributes.NAME); } arr.sort(); var tmp:String = ""; for(i=0; i<arr.length; i++) { tmp += arr + "<br>"; } tmp = tmp += "<br>"; content = content.replace("[OPENSHELTERSTOKEN]", tmp); var bkgrndColor:String = "0x00FF00"; HTMLPopup.show(content, btnLabel, txtareaWidth, txtareaHeight); } else { content = content.replace("[SHELTERMESSAGETOKEN]", sSheltersClosedMessage); HTMLPopup.show(content, btnLabel, txtareaWidth, txtareaHeight); } } private function onFault(info:Object, token:Object = null):void { trace("Fault"); } } ]]> </fx:Script> </viewer:BaseWidget>
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.