<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:esri="http://www.esri.com/2008/ags"> <fx:Script> <![CDATA[ import com.esri.ags.Graphic; import com.esri.ags.events.DrawEvent; import com.esri.ags.events.IdentifyEvent; import com.esri.ags.events.MapMouseEvent; import com.esri.ags.geometry.MapPoint; import com.esri.ags.layers.ArcGISDynamicMapServiceLayer; import com.esri.ags.layers.GraphicsLayer; import com.esri.ags.layers.Layer; import com.esri.ags.tasks.IdentifyTask; import com.esri.ags.tasks.supportClasses.IdentifyParameters; import com.esri.ags.tasks.supportClasses.IdentifyResult; import mx.collections.ArrayCollection; import mx.controls.TextArea; import mx.rpc.events.FaultEvent; [Bindable] private var msgVisible:Boolean = false; [Bindable] private var identifyArrayCollection:ArrayCollection; private var identifyPoint:MapPoint; //DECLARE CONTENT VARIABLE [Bindable] private var content:String = ""; private function myClickHandler(event:MapMouseEvent):void { //CLEAR CONTENT VARIABLE this.content = ""; identifyPoint = event.mapPoint; var myGraphic:Graphic = new Graphic(null,null,null); var identifyParams : IdentifyParameters = new IdentifyParameters(); identifyParams.returnGeometry = false; identifyParams.tolerance = 5; identifyParams.geometry = identifyPoint; identifyParams.width = myMap.width; identifyParams.height = myMap.height; identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_ALL; identifyParams.mapExtent = myMap.extent; for (var i:Number = myMap.layerIds.length -1; i >= 0; i--) { var layer:Layer = myMap.getLayer(myMap.layerIds); var url:String; if (layer.visible) { if (layer is ArcGISDynamicMapServiceLayer) { var dynamicLayer:ArcGISDynamicMapServiceLayer = layer as ArcGISDynamicMapServiceLayer; url = dynamicLayer.url ; } if(url) { var identifyTask:IdentifyTask = new IdentifyTask(url); identifyTask.addEventListener(IdentifyEvent.EXECUTE_COMPLETE, onResult); identifyTask.addEventListener(FaultEvent.FAULT, onFault); identifyTask.execute(identifyParams); showMessage("", true); } } } myMap.infoWindow.show(event.mapPoint); } private function drawEndHandler(event:DrawEvent):void { myGraphicsLayer.add(event.graphic); identifyPoint = event.graphic.geometry as MapPoint; } private function identifyFeatures():void { } private function processIdentifyResults(identifyResults:Array):void { if(!identifyArrayCollection) identifyArrayCollection = new ArrayCollection(); for each (var identifyResult:IdentifyResult in identifyResults) { var title:String = identifyResult.layerName; var obj:Object = identifyResult.feature.attributes; var fld:String; var value:String; for (fld in obj) { value = obj[fld].toString(); //APPEND TO CONTENT VARIABLE content += fld + ": " + value + "\n"; } //ADD LINE TO SEPERATE content += "\n------------------------\n"; } //PROCESS INFO WINDOW var text:TextArea = new TextArea(); text.text = content ; text.width = 300; text.height = 300; myMap.infoWindow.label = "Results" myMap.infoWindow.content=text; clearMessage(); } private function clearMessage():void { msgVisible = false; } private function onResult(event:IdentifyEvent):void { try { processIdentifyResults(event.identifyResults); } catch (error:Error) { showMessage(error.message, false); } } private function showMessage(msg:String, swfVisible:Boolean):void { msgVisible = true; } private function onFault(event:FaultEvent):void { showMessage(event.fault.faultDetail, false); } ]]> </fx:Script> <fx:Declarations> <esri:DrawTool id="drawToolbar" map="{myMap}" graphicsLayer="{myGraphicsLayer}" drawEnd="drawEndHandler(event)"/> <!-- Symbol for Point --> <esri:SimpleMarkerSymbol style="x" color="0xFF0000" size="12" /> </fx:Declarations> <esri:Map id="myMap" mapClick="myClickHandler(event)"> <esri:ArcGISDynamicMapServiceLayer url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Louisville/LOJIC_LandRecords_Louisville/MapServer" /> <esri:ArcGISDynamicMapServiceLayer url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Louisville/LOJIC_PublicSafety_Louisville/MapServer"/> <esri:GraphicsLayer id="myGraphicsLayer" /> </esri:Map> </s:Application>
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.