Feature Layer Automatic Select

2371
3
09-26-2012 06:32 AM
TylerWaring
Occasional Contributor II
Greetings,

I have a number of feature layers in an application that I would like to toggle selectability for. I am trying to mimic the functionality that is exhibited in the Edit widget. I would like have a set of feature layers selectable by default. However, when the user selects my widget's tool, I would like to toggle off the selectability of my feature layers until the user stops using my widget's tool. Could someone point me in the right direction?

Thanks, Tyler
Tags (2)
0 Kudos
3 Replies
philippschnetzer
Occasional Contributor III
Tyler,

This might help you...some links which describe what needs to be done to automatically add a layer to the map when a widget is opened.  I use this to show where streetview is available by adding a layer I created to the map when the streetview widget is opened.

http://forums.arcgis.com/threads/57108-Show-layer-when-widget-opens

http://forums.arcgis.com/threads/14345-FlexViewer-2.1-Add-Layer-to-the-map-when-a-widget-is-activate...
0 Kudos
IvanBespalov
Occasional Contributor III
Tyler,

this is extended ESRI sample:
<?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"
      initialize="application1_initializeHandler(event)"
      pageTitle="Using the Editor component">
 <!--
 This sample shows you how to use the editor component.
 -->
 
 <s:layout>
  <s:VerticalLayout/>
 </s:layout>
 
 <fx:Style>
  @namespace s "library://ns.adobe.com/flex/spark";
  @namespace mx "library://ns.adobe.com/flex/mx";
  @namespace esri "http://www.esri.com/2008/ags";
  
  esri|InfoWindow
  {
   background-color: #FFFFFF;
   border-thickness: 2;
  }
 </fx:Style>
 
 <fx:Script>
  <![CDATA[
   import mx.events.FlexEvent;
   
   protected function application1_initializeHandler(event:FlexEvent):void
   {
    myEditor.featureLayers = [ incidentsAreas ];
   }

   protected function myToolActivityChange(event:Event):void
 {
 myEditor.editTool.deactivate();
 incidentsAreas.clearSelection();
 myEditor.featureLayers = boxMayToolActive.selected ? null : [ incidentsAreas ];
 myEditor.map = boxMayToolActive.selected ? null : myMap;
 }

  ]]>
 </fx:Script>
 
 <fx:Declarations>
  <esri:GeometryService id="myGeometryService" url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"/>
 </fx:Declarations>
 
 <s:HGroup width="100%"
 horizontalAlign="center">
 <s:CheckBox label="My Tool is Active" 
 id="boxMayToolActive"
 selected="false"
 fontSize="18"
 change="myToolActivityChange(event)"/>
 </s:HGroup> 
 
 <esri:Map id="myMap" wrapAround180="true">
  <esri:extent>
   <esri:Extent id="socal"
       xmin="-13471000" ymin="3834000" xmax="-12878000" ymax="4124000">
    <esri:SpatialReference wkid="102100"/>
   </esri:Extent>
  </esri:extent>
  <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
  <esri:FeatureLayer id="incidentsAreas"
         mode="snapshot"
         outFields="[data_security,description]"
         url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/FeatureServer..."/>
 </esri:Map>
 
 <esri:Editor id="myEditor"
     width="100%" height="200"
     geometryService="{myGeometryService}"
     map="{myMap}"/>
</s:Application>
0 Kudos
TylerWaring
Occasional Contributor II
Thanks for replying Ivan and Phillip,

I believe that I may be venturing off into no person�??s land. I am trying my best to code my way toward an editing solution that has all of the functionality of the Edit widget but with the added value of attribute validation. There is currently no way to validate attribution for new or existing features using the Editor class.

I have decided to move ahead and create a custom tool that utilizes the draw tool to create an initial graphic. Once the graphic is completed, I then popup an infoWindow that is used to enter (textInput) or select (comboBox) field attributes. Once the field attributes are entered and the user clicks the OK button, a number of validation checks are run before passing the drawn graphic and attributes to the featureLayer using the applyEdits method. This all works rather well but I still need to offer the user the ability to edit the attributes and geometries of existing features.

To edit the attributes, I plan to use an attribute inspector. Though I have not yet implemented the attribute inspector I believe it will work well for my purposes but I cannot figure out a way to provide the user with the ability to alter the geometries of existing features. However, I cannot figure out a way to decouple the select/edit geometry functionality from the edit widget so that I can create features and validate attributes, update and validate attributes and edit geometry. I am looking for some kind of way that I can toggle my featureLayer�??s selectability  on or off depending on if the user is creating a new feature.

Any ideas or suggestions?

Thanks, Tyler
0 Kudos