hi,
can anyone give an example on how to apply edits while editing two layers in arcgis javasscript
Don't forget to mark this question as answered by clicking on the "Correct Answer" link on the reply that answered your question.
Hi Robert,
I coudnt find ur code please post again
Yes the code and sample I provided does not use any template picker it is low level custom editing you have to do all the work in your code concerning setting attributes and geometries to the array of graphics and then use FeatureLayer.applyEdits.
hello panagiotis,
Can we do that withoust using templatepicker
here is also a sample from Javascript API
ArcGIS API for JavaScript Sandbox
hello robert,
can we do that without using template picker
Here is the code snippet you can use. Create the separate variables for each feature layer. Hope it helps.
<!DOCTYPE html><html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> <title></title>
<link rel="stylesheet" href="https://js.arcgis.com/3.18/dijit/themes/claro/claro.css"> <link rel="stylesheet" href="https://js.arcgis.com/3.18/esri/css/esri.css"> <style> html,body{height:100%;width:100%;margin:0;overflow:hidden;} #map{ padding:0; } #header{ font-size: 1.1em; font-family: sans-serif; padding-left: 1em; padding-top:4px; color:#660000; } .templatePicker { border: none; }
.dj_ie .infowindow .window .top .right .user .content { position: relative; } .dj_ie .simpleInfoWindow .content { position: relative; } </style>
<script src="https://js.arcgis.com/3.18/"></script> <script> var map;
require([ "esri/map", "esri/tasks/GeometryService",
"esri/layers/ArcGISDynamicMapServiceLayer", "esri/layers/FeatureLayer",
"esri/Color", "esri/symbols/SimpleMarkerSymbol", "esri/symbols/SimpleLineSymbol",
"esri/dijit/editing/Editor", "esri/dijit/editing/TemplatePicker",
"esri/config", "dojo/i18n!esri/nls/jsapi",
"dojo/_base/array", "dojo/parser", "dojo/keys",
"dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dojo/domReady!" ], function( Map, GeometryService, ArcGISDynamicMapServiceLayer, FeatureLayer, Color, SimpleMarkerSymbol, SimpleLineSymbol, Editor, TemplatePicker, esriConfig, jsapiBundle, arrayUtils, parser, keys ) { parser.parse();
// snapping is enabled for this sample - change the tooltip to reflect this jsapiBundle.toolbars.draw.start = jsapiBundle.toolbars.draw.start + "<br>Press <b>ALT</b> to enable snapping";
// refer to "Using the Proxy Page" for more information: https://developers.arcgis.com/javascript/3/jshelp/ags_proxy.html esriConfig.defaults.io.proxyUrl = "/proxy/";
//This service is for development and testing purposes only. We recommend that you create your own geometry service for use within your applications. esriConfig.defaults.geometryService = new GeometryService("https://utility.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
map = new Map("map", { basemap: "topo", center: [-88.55, 43.12], zoom: 9, slider: false });
map.on("layers-add-result", initEditor);
//add boundaries and place names var labels = new ArcGISDynamicMapServiceLayer("Enter the URL of your Mapserver"); map.addLayer(labels);
// If your features are points. var responsePoints = new FeatureLayer("YourURL/FeatureServer/1", { mode: FeatureLayer.MODE_ONDEMAND, outFields: ['*'] });
//If your features are a polygon var responsePolys = new FeatureLayer("YourURL/FeatureServer/5", { mode: FeatureLayer.MODE_ONDEMAND, outFields: ['*'] });
map.addLayers([responsePolys, responsePoints]);
function initEditor(evt) { var templateLayers = arrayUtils.map(evt.layers, function(result){ return result.layer; }); var templatePicker = new TemplatePicker({ featureLayers: templateLayers, grouping: true, rows: "auto", columns: 3 }, "templateDiv"); templatePicker.startup();
var layers = arrayUtils.map(evt.layers, function(result) { return { featureLayer: result.layer }; }); var settings = { map: map, templatePicker: templatePicker, layerInfos: layers, toolbarVisible: true, createOptions: { polylineDrawTools:[ Editor.CREATE_TOOL_FREEHAND_POLYLINE ], polygonDrawTools: [ Editor.CREATE_TOOL_FREEHAND_POLYGON, Editor.CREATE_TOOL_CIRCLE, Editor.CREATE_TOOL_TRIANGLE, Editor.CREATE_TOOL_RECTANGLE ] }, toolbarOptions: { reshapeVisible: true } };
var params = { settings: settings }; var myEditor = new Editor(params, 'editorDiv'); //define snapping options var symbol = new SimpleMarkerSymbol( SimpleMarkerSymbol.STYLE_CROSS, 15, new SimpleLineSymbol( SimpleLineSymbol.STYLE_SOLID, new Color([255, 0, 0, 0.5]), 5 ), null ); map.enableSnapping({ snapPointSymbol: symbol, tolerance: 20, snapKey: keys.ALT });
myEditor.startup(); } }); </script></head><body class="claro"><div id="main" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline'" style="width:100%;height:100%;"> <div data-dojo-type="dijit/layout/ContentPane" id="header" data-dojo-props="region:'top'"> Edit USAR Location and Study Area </div> <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'left'" style="width: 300px;overflow:hidden;"> <div id="templateDiv"></div> <div id="editorDiv"></div> </div> <div data-dojo-type="dijit/layout/ContentPane" id="map" data-dojo-props="region:'center'"></div></div></body></html>
Bharath,
You will have to apply the edits to each layer separately. You will have to have a FeatureService url for each and add a FeatureLayer to the map using that FeatureService url:
featureLayer.applyEdits(features, null, null);<SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
FeatureLayer | API Reference | ArcGIS API for JavaScript 3.18 | ApplyEdits
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.