功能需要Editor组件,FeatureLayer和GeometryService几个组件配合使用才能完成。
Server主要有:GeometryServer,MapServer,FeatureServer,ImageServer。
Editor它需要FeatureLayer的url是FeatureServer的服务才能进行编辑, 属性outFields的OBJECTID不可用,outFields展示的字段是表示可编辑的字段。
Editor的编辑Template是FeatureServer的原本属性字段。
toolbarVisible="true" 工具栏 (实现,增,删,改)
toolbarCutVisible="true" 剪切按钮(剪开之后geometry分成几个部分,没有丢失)
toolbarMergeVisible="true" 合并按钮(几个geometry部分合并成一块)
toolbarReshapeVisible="true" 修正按钮(去掉部分边角)
三个按钮都添加之后,工具栏就全了
demo:
<?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" xmlns:esri="http://www.esri.com/2008/ags" initialize="application1_initializeHandler(event)" pageTitle="Editor with all toolbar options"> <!-- This sample shows you how to use the editor component with a full toolbar. --> <fx:Style> @namespace esri "http://www.esri.com/2008/ags"; esri|InfoWindow { background-color : #FFFFFF; border-thickness : 2; } </fx:Style> <fx:Script> <![CDATA[ import com.esri.ags.components.supportClasses.CreateOptions; import com.esri.ags.tasks.GeometryService; import com.esri.ags.tools.DrawTool; import mx.events.FlexEvent; protected function application1_initializeHandler(event:FlexEvent):void { myEditor.featureLayers = [ fireAreas ]; var myDrawTypePreferences:CreateOptions = new CreateOptions(); // change the defauls drawing tool from "point-to-point" to "freehand" myDrawTypePreferences.polygonDrawTools = [ DrawTool.FREEHAND_POLYGON, DrawTool.POLYLINE, CreateOptions.AUTO_COMPLETE ]; myEditor.createOptions = myDrawTypePreferences; } ]]> </fx:Script> <mx:VBox width="100%" height="100%"> <esri:Map id="myMap" wrapAround180="true"> <esri:extent> <esri:Extent id="sheepfire" xmin="-13144000" ymin="4033000" xmax="-13066000" ymax="4099000"> <esri:SpatialReference wkid="102100"/> </esri:Extent> </esri:extent> <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/> <esri:FeatureLayer id="fireAreas" mode="snapshot" outFields="*" url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/FeatureServer/2"/> </esri:Map> <esri:Editor id="myEditor" width="100%" geometryService="{new GeometryService('http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer')}" map="{myMap}" toolbarCutVisible="true" toolbarMergeVisible="true" toolbarReshapeVisible="true" toolbarVisible="true"/> <s:Label width="100%" text="This feature layer has {fireAreas.numGraphics} ({fireAreas.selectedFeatures.length} selected) fire areas."/> </mx:VBox> </s:Application>