<?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>
//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(); }
//updateGeometry
if (configXML.updategeometry.length() > 0)
{
updateGeometry = configXML.updategeometry == "true";
}
editor.updateGeometryEnabled = updateGeometry;