Select to view content in your preferred language

Editor updates geometry regardless of updateGeometryEnabled=false

797
6
01-09-2012 08:20 PM
MarkHoyland
Occasional Contributor II
I am finding some interesting things with the Editor component.
Editor updates geometry regardless of updateGeometryEnabled=false.

All I want to do is edit attributes as part of a workflow.
If I click a feature once and the attribute window opens as expected, click it a second time I can the move the vertices, click a third time I can move the entire feature.
Any ideas why this is happening?

I want to take advantage of the Editor components undo and redo feature.

<?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.layers.FeatureLayer;
   import com.esri.ags.tools.EditTool;
   
   import mx.events.FlexEvent;
   
   protected function editor_creationCompleteHandler(event:FlexEvent):void
   {
    var editTool:EditTool = editor.editTool;
    editTool.allowAddVertices = false;
    editTool.allowDeleteVertices = false;
    
    editor.templatePicker.visible = false;
    editor.templatePicker.includeInLayout = false;
    editor.selectionDropDownList.visible = false;
    editor.selectionDropDownList.includeInLayout = false;
    editor.deleteButton.visible = false;
    editor.deleteButton.includeInLayout = false;
    editor.drawDropDownList.visible = false;
    editor.drawDropDownList.includeInLayout = false;
   }
  ]]>
 </fx:Script>
 
 <esri:Map id="map">
  <esri:extent>
   <esri:WebMercatorExtent minlon="-97.53" minlat="37.43" maxlon="-97.26" maxlat="37.64"/>
  </esri:extent>
  <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
  <esri:ArcGISDynamicMapServiceLayer id="opsLayer" url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSFields/MapServer"/>
  <esri:FeatureLayer id="featureLayer"
         mode="selection"
         outFields="[activeprod, field_name, polydate, status, prod_oil]"
         url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSFields/FeatureServer/0"/>
 </esri:Map>
 <s:BorderContainer x="55" y="10"  >
  <esri:Editor id="editor" width="300" 
      addEnabled="false"
      deleteEnabled="false"
      updateAttributesEnabled="true" 
      updateGeometryEnabled="false"
      creationComplete="editor_creationCompleteHandler(event)" 
      featureLayers="{[featureLayer]}" 
      map="{map}" 
      toolbarCutVisible="true" toolbarMergeVisible="true" toolbarReshapeVisible="false" 
      toolbarVisible="true"/>
      
 </s:BorderContainer>
</s:Application>
Tags (2)
0 Kudos
6 Replies
MarkHoyland
Occasional Contributor II
I have come up with a workaround to this issue.
This works for my paticular case as I only need to deal with one feature at a time.
This workaround acts like a toggle to show/close the AttributeInpector window.
Click once on the feature and thefeature will be selected and have the AttributeInpector shown.
Click a second time on the feature and the feature will be de-selected and the AttributeInpector will close.


//add listeners when the editor component is created.
editor.attributeInspector.addEventListener(AttributeInspectorEvent.SHOW_FEATURE,attribute_showHandler);
map.infoWindow.addEventListener(Event.CLOSE,attribute_closeHandler);

/**
 * Removes listener from the attributeInspector's activeFeature.
 */
protected function attribute_closeHandler(event:Event):void
{
 if (editor.attributeInspector.activeFeature)
 {
  editor.attributeInspector.activeFeature.removeEventListener(MouseEvent.CLICK,attributeFeature_clickHandler);
 }
}

/**
 * Adds listener to the attributeInspector's activeFeature.
 */
protected function attribute_showHandler(event:AttributeInspectorEvent):void
{
 event.feature.addEventListener(MouseEvent.CLICK,attributeFeature_clickHandler);
}

/**
 * Clears the FeatureLayers selection. Clearing the selection will also trigger the attribute_closeHandler.
 * Workaround to prevent the user moving the features vertices or moving the entire feature.
 * Without this, the feature will show vertice's on the second click, and the entire graphic will be able to be moved on the third click, 
 * even with editor.updateGeometryEnabled="false".
 */
protected function attributeFeature_clickHandler(event:MouseEvent):void
{
 featureLayer.clearSelection();
}

0 Kudos
PatrickMullen1
New Contributor III
Hey Mark,

I am looking to incorporate your code into my edit widget but can't figure out where the code should be placed. Can you please give me some direction?

Thanks,
Patrick
0 Kudos
MarkHoyland
Occasional Contributor II
Patrick,
The code I added was a quick workaraound but not entirely foolproof. If th euser qwuiclky double or triple clicks a selected feature, the vertice's and move handles would still come up. Plus I had some extra requirements oustside of the attribute Inspector that was giving me some grief.
So I have come up with a different solution by extending the Editor component. I am in the testing phase at the moment and will post here when finished.
Depending on your requirements it may be a better solution.
What exactly are you trying to achieve. What is your workflow or use case.
If you able post your widget code I can have a look at what you need.
0 Kudos
PatrickMullen1
New Contributor III
Thanks for the reply Mark.

The workflow is quite simple. I have a feature class that holds property management data. Due to the ever changing nature of the data and how it comes from multiple sources within the organization, I thought having an editable layer on the flexviewer would offer a quick way to access and edit the data. But I do not want users to be able to edit the geometries of the data.

I was looking for something like this. http://help.arcgis.com/en/webapi/flex/samples/index.html#/Attribute_Inspector_edit/01nq0000005z00000...

I have this working but not sure how to implement the search widget inside of that application because the edit feature would be useless if users cant easily locate the property.

So very simply, I just need to disable updating geometries.

Patrick
0 Kudos
aureliensebert
New Contributor
Thanks for the quick workaround but it is strange !

i use the FLEX API agslib-2.5-2011-11-30.swc and Editor updates geometry regardless of updateGeometryEnabled=false !!

i have tested the edit widget of the Flexviewer 2.5 with updategeometry="false" in the configXML and it's work fine while the logic is the same as previously !!!!

EDIT WIDGET CODE :

    //updateGeometry
                    if (configXML.updategeometry.length() > 0)
                    {
                        updateGeometry = configXML.updategeometry == "true";
                    }
editor.updateGeometryEnabled = updateGeometry;
0 Kudos
PriyaRam
Deactivated User
I think its a bug in FlexViewer 2.5 and it seems to be working in 3.0 API
.
0 Kudos