Select to view content in your preferred language

Populate combobox with a layer from a map service.

1992
12
12-08-2010 08:00 AM
JasonLevine
Deactivated User
I've been searching for the proper way of doing this, but I've only found how to populate a combobox with the results from a query.  Basically, I'd like to create an ArrayCollection that contains all of the features of a single layer in a map service and use it as the data provider for my combobox. When a user clicks a feature in that layer in the combobox, the map will zoom to that feature.

I've put together the following code, but I'm definitely on the wrong track.  Any help is appreciated.
<?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:esri="http://www.esri.com/2008/ags"
      pageTitle="Map Extent and Mouse Coordinates" 
      creationComplete="combobox()">
 
 <fx:Script>
  <![CDATA[
   
   import mx.collections.ArrayCollection;
  
   private function combobox():void
   {
    var comboArray:ArrayCollection = new ArrayCollection();
    comboArray = comm_layer.layerInfos.Communities_Places //the specific layer in the map service
    cmb.dataProvider = comboArray;
    cmb.labelField = comboArray.comm_name_ //field within the Communities_Places layer
   }
     
  ]]>
 </fx:Script>
 
 <s:layout>
  <s:VerticalLayout paddingTop="6"/>
 </s:layout>
 
 <s:HGroup>
  <s:ComboBox id="cmb" right="250"/>
 </s:HGroup>
 
 <esri:Map id="myMap">
  <esri:extent>
   <esri:Extent xmin="-13338986.2116637" ymin="3926661.77417242" xmax="-13002755.460699" ymax="4152028.76378653">
    <esri:SpatialReference wkid="3857"/>
   </esri:Extent>
  </esri:extent>
  <esri:ArcGISDynamicMapServiceLayer id="comm_layer" url="http://10.2.8.73/ArcGIS/rest/services/ZNET_Public/city_maskForExtent/MapServer"/>
 </esri:Map>

</s:Application>


Thanks,
Jason
Tags (2)
0 Kudos
12 Replies
LemvigKommune
Deactivated User
Hi June

I've got it to work with a autocompletebox from Hillel Corel (i think), i'll post the code and the widget in a few days, it works with points, lines and polygons.

i'm working on getting it to run multible queries, so that you can point to more than on layer in the config-file of the widget, so if you have a point-layer with adresses and a polygon-layer with parcel-numbers you can get it in the same list.

i'll hope for it to be complete just after new years eve.

Mads Gren
Lemvig
Denmark.
0 Kudos
DasaPaddock
Esri Regular Contributor
Dasa,

I used the code you posted with a point layer. I get weird results with the zoom... does the code work for a point layer or just for a polygon layer?

june


My sample won't work as-is with a point layer since points don't have valid extents. See this code for an example of how to set the center and scale instead:

http://forums.arcgis.com/threads/20162-modify-Find-Task-Zoom-In-Results-Sample?p=65000&viewfull=1#po...
0 Kudos
LemvigKommune
Deactivated User
Dasa,

I used the code you posted with a point layer. I get weird results with the zoom... does the code work for a point layer or just for a polygon layer?

june


Hi June

I've put my AutocompleteSearch widget on arcgis.com - search for flex widget, hope it can help.

Mads Gren
Lemvig Kommune
Denmark
0 Kudos