<?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" minWidth="1024" minHeight="768" xmlns:esri="http://www.esri.com/2008/ags" xmlns:mx="library://ns.adobe.com/flex/mx" > <fx:Declarations> <!--Queried layer--> <esri:QueryTask id="queryTask" url="http://mapserver.ujep.cz/ArcGIS/rest/services/Projekty/Lomy/MapServer/0"/> <!--Querry the type of rock (Hornina)--> <esri:Query id="query" where="Hornina='{typesChoose.selectedItem}'" returnGeometry="true" outSpatialReference="{mainMap.spatialReference}"> <esri:outFields> <fx:String>Umisteni</fx:String> <fx:String>Majitel</fx:String> <fx:String>Kontakt</fx:String> <fx:String>Zrnitost</fx:String> <fx:String>Hornina</fx:String> </esri:outFields> </esri:Query> </fx:Declarations> <esri:Map id="mainMap"> <esri:extent> <esri:Extent xmax="-885425.789" ymax="-954466.567" xmin="-702106.51" ymin="-1044718.028"> <esri:SpatialReference wkid="102067"/> </esri:Extent> </esri:extent> <esri:ArcGISTiledMapServiceLayer url="http://mapserver.ujep.cz/ArcGIS/rest/services/NAKI/Data200_cached/MapServer"/> <esri:GraphicsLayer id="myGraphicsLayer" graphicProvider="{queryTask.executeLastResult.features}"> <esri:renderer> <esri:SimpleRenderer> <esri:SimpleMarkerSymbol id="basicSmybol" color="red" style="diamond"/> </esri:SimpleRenderer> </esri:renderer> </esri:GraphicsLayer> </esri:Map> <s:Panel top="50" right="50" id="leftPanel" width="350" height="400"> <s:layout> <s:VerticalLayout horizontalAlign="left" paddingLeft="10" paddingRight="10" paddingTop="10" paddingBottom="10" /> </s:layout> <!--Choose the rock type--> <s:ComboBox id="typesChoose" selectedItem=" " width="75%" change="queryTask.execute(query)"> <s:ArrayCollection> <fx:String>B�?idlice</fx:String> <fx:String>�?edič</fx:String> <fx:String>Rula</fx:String> <fx:String>Vápenec</fx:String> <fx:String>Žula</fx:String> </s:ArrayCollection> </s:ComboBox> <mx:DataGrid id="resultsGrid" width="100%" height="100%" dataProvider="{queryTask.executeLastResult.attributes}"> <mx:columns> <mx:DataGridColumn headerText="Umíst�?ní" dataField="Umisteni" /> <mx:DataGridColumn headerText="Majitel" dataField="Majitel" width="130"/> <mx:DataGridColumn headerText="Kontakt" dataField="Kontakt"/> </mx:columns> </mx:DataGrid> </s:Panel> </s:Application>
<?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" pageTitle="Query, then zoom to results"> <fx:Script> <![CDATA[ import com.esri.ags.FeatureSet; import com.esri.ags.Graphic; import com.esri.ags.geometry.Extent; import com.esri.ags.geometry.Polygon; import mx.controls.Alert; import mx.rpc.AsyncResponder; [Bindable] private var lastIdentifyResultGraphic:Graphic; private function doQuery():void { query.text = fText.text; query.where = "*"; queryTask.execute(query, new AsyncResponder(onResult, onFault)); function onResult(featureSet:FeatureSet, token:Object = null):void { // clear the graphics layer myGraphicsLayer.clear(); if (featureSet.features.length == 0) { Alert.show("No States found. Please try again."); } else { var unionExtent:Extent; var myFirstGraphic:Graphic = featureSet.features[0]; unionExtent = Polygon(myFirstGraphic.geometry).extent; for each (var myGraphic1:Graphic in featureSet.features) { myGraphicsLayer.add(myGraphic1); unionExtent = unionExtent.union(Polygon(myGraphic1.geometry).extent); } MainMap.extent = unionExtent; } } function onFault(info:Object, token:Object = null):void { Alert.show("-->Error Here<--" + info.toString()); } } private function sfDataGrid_Click():void { var obj:Object = sfDataGrid.selectedItem; if (obj != null) { lastIdentifyResultGraphic = null; query.where = "CO_NAME = '" + obj["CO_NAME"] + "'"; queryTaskZoom.execute(query, new AsyncResponder(onResult, onFault)); function onResult(featureSet:FeatureSet, token:Object = null):void { lastIdentifyResultGraphic = featureSet.features[0]; lastIdentifyResultGraphic.symbol = sfs; MainMap.extent = new Extent(lastIdentifyResultGraphic.geometry.extent.xmin, lastIdentifyResultGraphic.geometry.extent.ymin, lastIdentifyResultGraphic.geometry.extent.xmax,lastIdentifyResultGraphic.geometry.extent.ymax); } function onFault(info:Object, token:Object = null):void { Alert.show("Query Problem ", info.toString()); } } } ]]> </fx:Script> <fx:Declarations> <!-- Symbol for Query Result as Polygon --> <esri:SimpleFillSymbol id="sfs" alpha="0.7" color="0xFF0000"/> <!-- Layer with US States --> <esri:QueryTask id="queryTask" showBusyCursor="true" url="http://geonexus/ArcGIS/rest/services/Boundaries/COUNTY_BORDERS_SO/MapServer/0"/> <esri:QueryTask id="queryTaskZoom" showBusyCursor="true" url="http://geonexus/ArcGIS/rest/services/Boundaries/COUNTY_BORDERS_SO/MapServer/0"/> <esri:Query id="query" text="{fText.text}" returnGeometry="true" outSpatialReference="{MainMap.spatialReference}"> <esri:outFields> <fx:String>CO_NUMBER</fx:String> <fx:String>COUNTY_YEAR</fx:String> </esri:outFields> </esri:Query> </fx:Declarations> <mx:VDividedBox height="100%" width="100%"> <mx:HBox width="100%" height="40" backgroundColor="0xDDDDFF" paddingTop="10" horizontalAlign="center"> <mx:Text text="Search for U.S. States:"/> <mx:TextInput id="fText" enter="doQuery();" text="Lyon"/> <mx:Button label="Query" click="doQuery();" enabled="true"/> </mx:HBox> <mx:Text id="resultSummary" height="15"/> <!--The map--> <esri:Map id="MainMap" openHandCursorVisible="false" level="7" logoVisible="false" extent="{new Extent(-10884964.57, 4660003.62, -9907264.87, 5649404.52, new SpatialReference(102113))}"> <esri:ArcGISTiledMapServiceLayer url="http://geonexus/ArcGIS/rest/services/Basemap/Basemap/MapServer"/> <esri:GraphicsLayer id="myGraphicsLayer" symbol="{sfs}" graphicProvider="{lastIdentifyResultGraphic}"/> </esri:Map> <mx:DataGrid id="sfDataGrid" click="sfDataGrid_Click()" dataProvider="{queryTask.executeLastResult.attributes}" scroll="true" width="100%" height="40%"/> </mx:VDividedBox> </s:Application>
<esri:SimpleFillSymbol id="symbol1" style="solid" color="0xFF0000" alpha="0.3"> <esri:outline> <esri:SimpleLineSymbol style="solid" color="0x000000" width="2" /> </esri:outline> </esri:SimpleFillSymbol> <esri:SimpleFillSymbol id="selSymbol" style="solid" color="0x22BB99" alpha="1"> </esri:SimpleFillSymbol>
private function selectRow(event:ListEvent):void { var selectedGraphic:Graphic; var attr:Object = event.itemRenderer.data; var i:int=0; for each (var graphic:Graphic in graphicsLayer.graphicProvider) { graphic.symbol=symbol1; i++; if (graphic.attributes == attr){ selectedGraphic=graphic; selectedGraphic.symbol=selSymbol; graphicsLayer.moveToTop(selectedGraphic); zoomToRow(selectedGraphic); } } } private function zoomToRow(graphic:Graphic):void { var offset:int=3000; var graphicsExtent:Extent; if (graphic){ graphicsExtent = graphic.geometry.extent; graphicsExtent.xmax=graphicsExtent.xmax+offset; graphicsExtent.xmin=graphicsExtent.xmin-offset; graphicsExtent.ymax=graphicsExtent.ymax+offset; graphicsExtent.ymin=graphicsExtent.ymin-offset; map1.extent = graphicsExtent; // make sure the whole extent is visible if (!map1.extent.containsExtent(graphicsExtent)){ map1.level--; } } }
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:esri="http://www.esri.com/2008/ags" pageTitle="Query, then zoom to results" styleName="plain"> <mx:Script> <![CDATA[ import com.esri.ags.geometry.Extent; import com.esri.ags.Graphic; import com.esri.ags.geometry.Polygon; import com.esri.ags.tasks.FeatureSet; import mx.controls.Alert; import mx.rpc.AsyncResponder; [Bindable] private var lastIdentifyResultGraphic:Graphic; private function doQuery():void { query.text = fText.text query.where = "" queryTask.execute(query, new AsyncResponder(onResult, onFault)); function onResult(featureSet:FeatureSet, token:Object = null):void { // clear the graphics layer myGraphicsLayer.clear(); if (featureSet.features.length == 0) { Alert.show("No States found. Please try again."); } else { var unionExtent:Extent; var myFirstGraphic:Graphic = featureSet.features[0]; unionExtent = Polygon(myFirstGraphic.geometry).extent; for each (var myGraphic1:Graphic in featureSet.features) { myGraphicsLayer.add(myGraphic1); unionExtent = unionExtent.union(Polygon(myGraphic1.geometry).extent); } MainMap.extent = unionExtent; } } function onFault(info:Object, token:Object = null):void { Alert.show(info.toString()); } } private function sfDataGrid_Click():void { var obj:Object = sfDataGrid.selectedItem; if (obj != null) { lastIdentifyResultGraphic = null; query.where = "STATE_NAME = '" + obj["STATE_NAME"] + "'" queryTaskZoom.execute(query, new AsyncResponder(onResult, onFault)); function onResult(featureSet:FeatureSet, token:Object = null):void { lastIdentifyResultGraphic = featureSet.features[0]; lastIdentifyResultGraphic.symbol = sfs; MainMap.extent = new Extent(lastIdentifyResultGraphic.geometry.extent.xmin,lastIdentifyResultGraphic.geometry.extent.ymin,lastIdentifyResultGraphic.geometry.extent.xmax,lastIdentifyResultGraphic.geometry.extent.ymax); } function onFault(info:Object, token:Object = null):void { Alert.show(info.toString(), "Query Problem"); } } } ]]> </mx:Script> <!-- Start Declarations --> <!-- Symbol for Query Result as Polygon --> <esri:SimpleFillSymbol id="sfs" alpha="0.7" color="0xFF0000"/> <!-- Layer with US States --> <esri:QueryTask id="queryTask" url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"/> <esri:QueryTask id="queryTaskZoom" url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"/> <esri:Query id="query" text="{fText.text}" returnGeometry="true" outSpatialReference="{MainMap.spatialReference}"> <esri:outFields> <mx:String>MED_AGE</mx:String> <mx:String>POP2007</mx:String> </esri:outFields> </esri:Query> <!-- End Declarations --> <mx:HBox width="100%" height="40" backgroundColor="0xDDDDFF" paddingTop="10" horizontalAlign="center"> <mx:Text text="Search for U.S. States:"/> <mx:TextInput id="fText" enter="doQuery()" text="Ca"/> <mx:Button label="Query" click="doQuery()"/> </mx:HBox> <mx:Text id="resultSummary" height="15"/> <mx:VDividedBox height="100%" width="100%"> <esri:Map id="MainMap"> <esri:extent> <esri:Extent xmin="-126" ymin="24" xmax="-67" ymax="50"> <esri:SpatialReference wkid="4326"/> </esri:Extent> </esri:extent> <esri:ArcGISDynamicMapServiceLayer url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer"/> <esri:GraphicsLayer id="myGraphicsLayer" symbol="{sfs}" graphicProvider="{lastIdentifyResultGraphic}"/> </esri:Map> <mx:DataGrid id="sfDataGrid" click="sfDataGrid_Click()" dataProvider="{queryTask.executeLastResult.attributes}" scroll="true" width="100%" height="40%"/> </mx:VDividedBox> </mx:Application>
TypeError: Error #1034: Type Coercion failed: cannot convert com.esri.ags::Graphic@5c8a0b1 to com.esri.ags.layers.GraphicsLayer. at testing/private:sfDataGrid_Click/onResult() at mx.rpc::AsyncResponder/result() at com.esri.ags.tasks::QueryTask/handleDecodedObject() at Function/http://adobe.com/AS3/2006/builtin::call() at com.esri.ags.tasks::BaseTask/handleResult() at <anonymous>() at mx.rpc::Responder/result() at mx.rpc::AsyncToken/http://www.adobe.com/2006/flex/mx/internal::applyResult() at mx.rpc.events::ResultEvent/http://www.adobe.com/2006/flex/mx/internal::callTokenResponders() at HTTPOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent() at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler() at mx.rpc::Responder/result() at mx.rpc::AsyncRequest/acknowledge() at DirectHTTPMessageResponder/completeHandler() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at flash.net::URLLoader/onComplete()
<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:esri="http://www.esri.com/2008/ags" pageTitle="Query, then zoom to results" styleName="plain"> <mx:Script> <![CDATA[ import com.esri.ags.Graphic; import com.esri.ags.geometry.Polygon; import com.esri.ags.tasks.FeatureSet; import mx.controls.Alert; import mx.rpc.AsyncResponder; private function doQuery():void { queryTask.execute(query, new AsyncResponder(onResult, onFault)); function onResult(featureSet:FeatureSet, token:Object = null):void { // clear the graphics layer myGraphicsLayer.clear(); if (featureSet.features.length == 0) { Alert.show("No States found. Please try again."); } else { var unionExtent:Extent; var myFirstGraphic:Graphic = featureSet.features[0]; unionExtent = Polygon(myFirstGraphic.geometry).extent; for each (var myGraphic1:Graphic in featureSet.features) { myGraphicsLayer.add(myGraphic1); unionExtent = unionExtent.union(Polygon(myGraphic1.geometry).extent); } MainMap.extent = unionExtent; } } function onFault(info:Object, token:Object = null):void { Alert.show(info.toString()); } } private function sfDataGrid_Click():void { var obj:Object = sfDatagrid.selectedItem; if (obj != null) { var polyExtent:Extent = new Extent(obj["XMIN"],obj["YMIN"],obj["XMAX"],obj["YMAX"]); myGraphicsLayer = null; // this section will highlight the feature selected query.where = "STATE_NAME = '" + obj["STATE_NAME"] + "'" queryTask.execute(query, new AsyncResponder(onResult, onFault)); function onResult(featureSet:FeatureSet, token:Object = null):void { myGraphicsLayer = featureSet.features[0]; myGraphicsLayer.symbol = sfs; } function onFault(info:Object, token:Object = null):void { Alert.show(info.toString(), "Query Problem"); } MainMap.extent = polyExtent; if (!MainMap.extent.containsExtent(polyExtent)) MainMap.level--; } } ]]> </mx:Script> <!-- Start Declarations --> <!-- Symbol for Query Result as Polygon --> <esri:SimpleFillSymbol id="sfs" alpha="0.7" color="0xFF0000"/> <!-- Layer with US States --> <esri:QueryTask id="queryTask" url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"/> <esri:Query id="query" text="{fText.text}" returnGeometry="true" outSpatialReference="{MainMap.spatialReference}"> <esri:outFields> <mx:String>MED_AGE</mx:String> <mx:String>POP2007</mx:String> </esri:outFields> </esri:Query> <!-- End Declarations --> <mx:HBox width="100%" height="40" backgroundColor="0xDDDDFF" paddingTop="10" horizontalAlign="center"> <mx:Text text="Search for U.S. States:"/> <mx:TextInput id="fText" enter="doQuery()" text="Ca"/> <mx:Button label="Query" click="doQuery()"/> </mx:HBox> <mx:Text id="resultSummary" height="15"/> <mx:VDividedBox height="100%" width="100%"> <esri:Map id="MainMap"> <esri:extent> <esri:Extent xmin="-126" ymin="24" xmax="-67" ymax="50"> <esri:SpatialReference wkid="4326"/> </esri:Extent> </esri:extent> <esri:ArcGISDynamicMapServiceLayer url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer"/> <esri:GraphicsLayer id="myGraphicsLayer" symbol="{sfs}"/> </esri:Map> <mx:DataGrid id="sfDatagrid" click="sfDataGrid_Click()" dataProvider="{queryTask.executeLastResult.attributes}" scroll="true" width="100%" height="40%"/> </mx:VDividedBox></mx:Application>
private function sfDataGrid_Click():void { var obj:Object = sfDatagrid.selectedItem; if (obj != null) { var polyExtent:Extent = new Extent(obj["XMIN"],obj["YMIN"],obj["XMAX"],obj["YMAX"]); lastIdentifyResultGraphic = null; // this section will highlight the feature selected sfQuery.where = "Name = '" + obj["Name"] + "'" sfPolygonQueryTask.execute(sfQuery, new AsyncResponder(onResult, onFault)); function onResult(featureSet:FeatureSet, token:Object = null):void { lastIdentifyResultGraphic = featureSet.features[0]; lastIdentifyResultGraphic.symbol = sfsOutline; } function onFault(info:Object, token:Object = null):void { Alert.show(info.toString(), "Query Problem"); } MainMap.extent = polyExtent; if (!MainMap.extent.containsExtent(polyExtent)) MainMap.level--; } }
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.