protected function init():void { var query:com.esri.ags.tasks.supportClasses.Query = new com.esri.ags.tasks.supportClasses.Query(); query.outFields = [ "NAME_1" ]; query.outSpatialReference = map.spatialReference; query.returnGeometry = true; query.where = "1=1"; queryTask.execute(query); }
import com.esri.ags.tasks.supportClasses.Query;
<?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:esri="http://www.esri.com/2008/ags" xmlns:custom="components.*" xmlns:viewer="com.esri.viewer.*" widgetConfigLoaded="init()"> <fx:Declarations> <esri:QueryTask id="queryTask" executeComplete="queryTask_executeCompleteHandler(event)" showBusyCursor="true" url="http://167.193.56.180/ArcGIS/rest/services/Georgia_Beach/MapServer/0" useAMF="false"/> </fx:Declarations> <fx:Script> <![CDATA[ import com.esri.ags.Graphic; import com.esri.ags.events.MapEvent; import com.esri.ags.events.QueryEvent; import com.esri.ags.geometry.Extent; import com.esri.ags.geometry.Geometry; import com.esri.ags.geometry.MapPoint; import com.esri.ags.tasks.supportClasses.Query; import com.esri.ags.utils.GraphicUtil; import mx.collections.ArrayCollection; import mx.collections.ArrayList; import spark.events.IndexChangeEvent; protected function init():void { var query:Query = new Query(); query.outFields = [ "NAME_1" ]; query.outSpatialReference = map.spatialReference; query.returnGeometry = true; query.where = "1=1"; queryTask.execute(query); } protected function queryTask_executeCompleteHandler(event:QueryEvent):void { ddList.dataProvider = new ArrayList(event.featureSet.features); } protected function ddListLabelFunction(item:Graphic):String { return item.attributes["NAME_1"]; } protected function ddList_changeHandler(event:IndexChangeEvent):void { var pt:MapPoint = MapPoint(Graphic(ddList.selectedItem).geometry); var beachExtent:Extent = new Extent(pt.x - 100, pt.y -100, pt.x + 100, pt.y + 100); map.extent = beachExtent // make sure the whole extent is visible if (!map.extent.contains(beachExtent)) { map.level--; } } ]]> </fx:Script> <viewer:WidgetTemplate id="DropDown" width="300" height="200" > <viewer:layout> <s:HorizontalLayout horizontalAlign="center" verticalAlign="middle"/> </viewer:layout> <s:DropDownList id="ddList" width="200" change="ddList_changeHandler(event)" labelFunction="ddListLabelFunction" prompt="Choose a beach..."/> </viewer:WidgetTemplate> </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.