as long as the graphic geometry type matches what is published in your feature service you can call featureLayer.applyEdits() and pass it in within the 'adds' parameter.check out this sample for an example of the method in action.
var map, toolbar, symbol, geomTask; require([ "esri/map", "esri/layers/ArcGISDynamicMapServiceLayer", "esri/layers/FeatureLayer", "esri/toolbars/draw", "esri/graphic", "esri/symbols/SimpleMarkerSymbol", "esri/symbols/SimpleLineSymbol", "esri/symbols/SimpleFillSymbol", "dojo/parser", "dijit/registry", "dijit/form/Button", "dijit/form/ValidationTextBox", "esri/dijit/editing/Editor-all", "dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dojo/domReady!" ], function ( Map, ArcGISDynamicMapServiceLayer, FeatureLayer, Draw, Graphic, SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol, parser, registry, button, validationTextBox, editorAll, borderContainer, contentPane ) { parser.parse(); esri.config.defaults.geometryService = new esri.tasks.GeometryService("http://gisadev:6080/arcgis/rest/services/Utilities/Geometry/GeometryServer"); // Create the map map = new Map("map") streetsLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://gisaprd/ArcGIS/rest/services/SRSLandbase/MapServer", { "id": "Streets" }); map.addLayer(streetsLayer); map.on("load", createToolbar); dojo.connect(map, "onLayersAddResult", initEditor); //Add the editable feature layer to the map var ISS_Features = new esri.layers.FeatureLayer("http://gisadev:6080/arcgis/rest/services/ISS_Inspections/FeatureServer/0", { mode: esri.layers.FeatureLayer.MODE_ONDEMAND, outFields: ['*'] }); map.addLayers([ISS_Features]); RedlinePointLayer = new esri.layers.FeatureLayer("http://gisadev:6080/arcgis/rest/services/Redline_Test/FeatureServer/0", { mode: FeatureLayer.MODE_SNAPSHOT, editable: true, outFields: ["*"] }); map.addLayers([RedlinePointLayer]); // loop through all dijits, connect onClick event // listeners for buttons to activate drawing tools registry.forEach(function (d) { // d is a reference to a dijit // could be a layout container or a button if (d.declaredClass === "dijit.form.Button") { d.on("click", activateTool); } }); function activateTool() { var tool = this.label.toUpperCase().replace(/ /g, "_"); toolbar.activate(Draw[tool]); map.hideZoomSlider(); } function createToolbar(themap) { toolbar = new Draw(map); toolbar.on("draw-end", addToMap); } function addToMap(evt) { var symbol; toolbar.deactivate(); map.showZoomSlider(); switch (evt.geometry.type) { case "point": case "multipoint": symbol = new SimpleMarkerSymbol(); break; case "polyline": symbol = new SimpleLineSymbol(); break; default: symbol = new SimpleFillSymbol(); break; } var graphic = new Graphic(evt.geometry, symbol); map.graphics.add(graphic); //To save the redline I need to add the graphic to the redline feature class...... if (graphic.symbol = SimpleMarkerSymbol) { RedlinePointLayer.add(new esri.Graphic(graphic.geometry, RedlinePointLayer.symbol), null, null); } } function initEditor(results) { //only one layer var featureLayer = results[0].layer; var templatePicker = new esri.dijit.editing.TemplatePicker({ featureLayers: [featureLayer], rows: 'auto', groupingEnabled: false, columns: 1 }, 'editorDiv'); templatePicker.startup(); var layerInfos = [{ 'featureLayer': featureLayer, 'showAttachments': false, 'showDeleteButton': false, 'isEditable': true, 'fieldInfos': [ { 'fieldName': 'METER_NUMBER', 'isEditable': true, 'tooltip': 'METER_NUMBER', 'label': 'METER_NUMBER:' }, ] }]; //define the editor settings var settings = { map: map, templatePicker: templatePicker, layerInfos: layerInfos }; var params = { settings: settings }; //Create the editor widget var editorWidget = new esri.dijit.editing.Editor(params); editorWidget.startup(); //resize the info window (attribute inspector) map.infoWindow.resize(430, 245); } });
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.