<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Programatically add feature to Feature Layer with ArcGIS JavaScript API in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programatically-add-feature-to-feature-layer-with/m-p/351233#M32533</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've so far been able to add a feature layer from an ArcGIS server, and I've also been able to add an editor widget which allows me to draw to feature with the mouse. The added features are being correctly committed to the server, and are visible from other viewers as well as in the SDE database. I have also been able to add the Editor toolbar and edit the existing polygon features.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I'm now looking for a way to add a feature without using the widget, just using JavaScript code. The closest thing I found was &lt;A href="http://forums.esri.com/Thread.asp?c=206&amp;amp;f=2274&amp;amp;t=271592" rel="nofollow"&gt;http://forums.esri.com/Thread.asp?c=206&amp;amp;f=2274&amp;amp;t=271592&lt;/A&gt; but it discusses .NET and doesn't look similar to the way something like that would be achieved in Javascript. Where would the best starting point be for doing something like this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Jan 2015 16:18:08 GMT</pubDate>
    <dc:creator>DanielGray</dc:creator>
    <dc:date>2015-01-27T16:18:08Z</dc:date>
    <item>
      <title>Programatically add feature to Feature Layer with ArcGIS JavaScript API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programatically-add-feature-to-feature-layer-with/m-p/351233#M32533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've so far been able to add a feature layer from an ArcGIS server, and I've also been able to add an editor widget which allows me to draw to feature with the mouse. The added features are being correctly committed to the server, and are visible from other viewers as well as in the SDE database. I have also been able to add the Editor toolbar and edit the existing polygon features.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I'm now looking for a way to add a feature without using the widget, just using JavaScript code. The closest thing I found was &lt;A href="http://forums.esri.com/Thread.asp?c=206&amp;amp;f=2274&amp;amp;t=271592" rel="nofollow"&gt;http://forums.esri.com/Thread.asp?c=206&amp;amp;f=2274&amp;amp;t=271592&lt;/A&gt; but it discusses .NET and doesn't look similar to the way something like that would be achieved in Javascript. Where would the best starting point be for doing something like this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jan 2015 16:18:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programatically-add-feature-to-feature-layer-with/m-p/351233#M32533</guid>
      <dc:creator>DanielGray</dc:creator>
      <dc:date>2015-01-27T16:18:08Z</dc:date>
    </item>
    <item>
      <title>Re: Programatically add feature to Feature Layer with ArcGIS JavaScript API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programatically-add-feature-to-feature-layer-with/m-p/351234#M32534</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you want to simulate the full functionality of the widget, then you are in for a long haul. But it is possible to add in access to the feature layer by using graphics layers or a feature layer (to build the geometry) and then using the REST API's feature service (this is NOT the javascript API's feature layer) to do the addition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a link to the REST API Feature Service info on adding features.&lt;/P&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Add_Features/02r30000010m000000/" title="http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Add_Features/02r30000010m000000/"&gt;ArcGIS REST API&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This takes in JSON and then returns a response. I've done it and it works pretty well. You will most likely be interested in setting up authentication on the service too - and the link above has other references to it for using OAUTH 2 and other methods for authenticating access to REST endpoints.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Brent&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jan 2015 16:28:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programatically-add-feature-to-feature-layer-with/m-p/351234#M32534</guid>
      <dc:creator>BrentPorter</dc:creator>
      <dc:date>2015-01-27T16:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: Programatically add feature to Feature Layer with ArcGIS JavaScript API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programatically-add-feature-to-feature-layer-with/m-p/351235#M32535</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use the &lt;A href="https://developers.arcgis.com/javascript/jsapi/featurelayer-amd.html#applyedits" rel="nofollow noopener noreferrer" target="_blank"&gt;applyEdits&lt;/A&gt; method of the FeatureLayer to do this. I am writing an application where I am just changing the attributes of selected features. Since I'm allowing the user to make changes to the attributes of multiple features (featureSet), I'm not using the AttributeInspector, but a custom dialog where the user can select specific attributes from comboBoxes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;array.forEach(featureSet, function (feature) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; feature.attributes.Priority = registry.byId('cboPriority').get("value");
&amp;nbsp;&amp;nbsp;&amp;nbsp; feature.attributes.Management = registry.byId('cboManagement').get("value");
&amp;nbsp;&amp;nbsp;&amp;nbsp; feature.attributes.Criteria = registry.byId('cboCriteria').get("value");
});

layerFeatureLayer.applyEdits(null, featureSet, null, function () { console.log("Features updated!"); }, function (error) { console.log("Features not updated! ", error); });&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your case, you would use the first parameter of the applyEdits method to add a new feature. You would have to handle the geometry of the feature and make sure its attributes are set.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:30:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/programatically-add-feature-to-feature-layer-with/m-p/351235#M32535</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2021-12-11T16:30:45Z</dc:date>
    </item>
  </channel>
</rss>

