<?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 Feature layer created from JSON not drawing in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/feature-layer-created-from-json-not-drawing/m-p/618617#M57833</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to create a feature layer from a feature collection (json, converted from shapefile) but it's not showing on the map.&amp;nbsp; If I log the feature layer to the console I can see it contains the same number of features as the original json.&amp;nbsp; In the console, I can navigate through the features and see the geometries and attributes in the tree.&amp;nbsp; Problem is the features are not being drawn on the map for some reason.&amp;nbsp; Does anyone have any ideas?&amp;nbsp; My code is below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; 
 var layerDefinition = {
&amp;nbsp; "geometryType" : "esriGeometryPolygon",
&amp;nbsp; "objectIdField" : "FID",
&amp;nbsp; "drawingInfo" : {
&amp;nbsp;&amp;nbsp; "renderer" : {
&amp;nbsp;&amp;nbsp;&amp;nbsp; "type" : "simple"
&amp;nbsp;&amp;nbsp; }
&amp;nbsp; },
&amp;nbsp; "fields" : [{
&amp;nbsp;&amp;nbsp; "name" : "FID",
&amp;nbsp;&amp;nbsp; "alias" : "ID",
&amp;nbsp;&amp;nbsp; "type" : "esriFieldTypeOID"
&amp;nbsp; }, {
&amp;nbsp;&amp;nbsp; "name" : "ZONE_",
&amp;nbsp;&amp;nbsp; "alias" : "Zone",
&amp;nbsp;&amp;nbsp; "type" : "esriFieldTypeString"
&amp;nbsp; }, {
&amp;nbsp;&amp;nbsp; "name" : "FSR",
&amp;nbsp;&amp;nbsp; "alias" : "FSR",
&amp;nbsp;&amp;nbsp; "type" : "esriFieldTypeDouble"
&amp;nbsp; }]
 };
 var featureCollection = {
&amp;nbsp; "layerDefinition" : layerDefinition,
&amp;nbsp; "featureSet" : {
&amp;nbsp;&amp;nbsp; "features" : [],
&amp;nbsp;&amp;nbsp; "geometryType" : "esriGeometryPolygon"
&amp;nbsp; }
 };

 //define a popup template
 var popupTemplate = new PopupTemplate({
&amp;nbsp; title : "{ZONE_}",
&amp;nbsp; description : "{FSR}"
 });

 //create a feature layer based on the feature collection
 featureLayer = new FeatureLayer(featureCollection, {
&amp;nbsp; id : "ufmLayer",
&amp;nbsp; infoTemplate : popupTemplate,
&amp;nbsp; outFields : ["*"]
 });

 map.on("layers-add-result", function(results) {
&amp;nbsp; requestData();
 });
 map.addLayers([featureLayer]);

 function requestData() {

&amp;nbsp; var requestHandle = esriRequest({
&amp;nbsp;&amp;nbsp; url : "http://&amp;lt;server&amp;gt;/ResearchAndAnalysis/UFM_Edit/data/RockdaleUFMBase_min.json",
&amp;nbsp;&amp;nbsp; callbackParamName : "jsoncallback"
&amp;nbsp; });
&amp;nbsp; requestHandle.then(requestSucceeded, requestFailed);
 }

 function requestSucceeded(response, io) {
&amp;nbsp; //loop through the items and add to the feature layer
&amp;nbsp; var features = response.features;
&amp;nbsp; alert(features.length);
&amp;nbsp; var ufmData = [];
&amp;nbsp; dojo.forEach(features, function(feature) {
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; var attr = {};
&amp;nbsp;&amp;nbsp; attr["ZONE_"] = feature.attributes.ZONE_;
&amp;nbsp;&amp;nbsp; attr["FSR"] = feature.attributes.FSR;
&amp;nbsp;&amp;nbsp; var geometry = new Polygon(feature.geometry);
&amp;nbsp;&amp;nbsp; var graphic = new Graphic(geometry);
&amp;nbsp;&amp;nbsp; graphic.setAttributes(attr);
&amp;nbsp;&amp;nbsp; ufmData.push(graphic);
&amp;nbsp; });
&amp;nbsp; featureLayer.applyEdits(ufmData, null, null, addSucceeded, addFailed);
&amp;nbsp; console.log(featureLayer);
 }

 function requestFailed(error) {
&amp;nbsp; console.log(error);
 }

 function addFailed(error) {
&amp;nbsp; console.log(error);
 }

 function addSucceeded() {
&amp;nbsp; console.log("add succeeded");
 }

&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks very much for any help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ed&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 04 Feb 2014 23:04:25 GMT</pubDate>
    <dc:creator>EdSaunders</dc:creator>
    <dc:date>2014-02-04T23:04:25Z</dc:date>
    <item>
      <title>Feature layer created from JSON not drawing</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/feature-layer-created-from-json-not-drawing/m-p/618617#M57833</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to create a feature layer from a feature collection (json, converted from shapefile) but it's not showing on the map.&amp;nbsp; If I log the feature layer to the console I can see it contains the same number of features as the original json.&amp;nbsp; In the console, I can navigate through the features and see the geometries and attributes in the tree.&amp;nbsp; Problem is the features are not being drawn on the map for some reason.&amp;nbsp; Does anyone have any ideas?&amp;nbsp; My code is below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; 
 var layerDefinition = {
&amp;nbsp; "geometryType" : "esriGeometryPolygon",
&amp;nbsp; "objectIdField" : "FID",
&amp;nbsp; "drawingInfo" : {
&amp;nbsp;&amp;nbsp; "renderer" : {
&amp;nbsp;&amp;nbsp;&amp;nbsp; "type" : "simple"
&amp;nbsp;&amp;nbsp; }
&amp;nbsp; },
&amp;nbsp; "fields" : [{
&amp;nbsp;&amp;nbsp; "name" : "FID",
&amp;nbsp;&amp;nbsp; "alias" : "ID",
&amp;nbsp;&amp;nbsp; "type" : "esriFieldTypeOID"
&amp;nbsp; }, {
&amp;nbsp;&amp;nbsp; "name" : "ZONE_",
&amp;nbsp;&amp;nbsp; "alias" : "Zone",
&amp;nbsp;&amp;nbsp; "type" : "esriFieldTypeString"
&amp;nbsp; }, {
&amp;nbsp;&amp;nbsp; "name" : "FSR",
&amp;nbsp;&amp;nbsp; "alias" : "FSR",
&amp;nbsp;&amp;nbsp; "type" : "esriFieldTypeDouble"
&amp;nbsp; }]
 };
 var featureCollection = {
&amp;nbsp; "layerDefinition" : layerDefinition,
&amp;nbsp; "featureSet" : {
&amp;nbsp;&amp;nbsp; "features" : [],
&amp;nbsp;&amp;nbsp; "geometryType" : "esriGeometryPolygon"
&amp;nbsp; }
 };

 //define a popup template
 var popupTemplate = new PopupTemplate({
&amp;nbsp; title : "{ZONE_}",
&amp;nbsp; description : "{FSR}"
 });

 //create a feature layer based on the feature collection
 featureLayer = new FeatureLayer(featureCollection, {
&amp;nbsp; id : "ufmLayer",
&amp;nbsp; infoTemplate : popupTemplate,
&amp;nbsp; outFields : ["*"]
 });

 map.on("layers-add-result", function(results) {
&amp;nbsp; requestData();
 });
 map.addLayers([featureLayer]);

 function requestData() {

&amp;nbsp; var requestHandle = esriRequest({
&amp;nbsp;&amp;nbsp; url : "http://&amp;lt;server&amp;gt;/ResearchAndAnalysis/UFM_Edit/data/RockdaleUFMBase_min.json",
&amp;nbsp;&amp;nbsp; callbackParamName : "jsoncallback"
&amp;nbsp; });
&amp;nbsp; requestHandle.then(requestSucceeded, requestFailed);
 }

 function requestSucceeded(response, io) {
&amp;nbsp; //loop through the items and add to the feature layer
&amp;nbsp; var features = response.features;
&amp;nbsp; alert(features.length);
&amp;nbsp; var ufmData = [];
&amp;nbsp; dojo.forEach(features, function(feature) {
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; var attr = {};
&amp;nbsp;&amp;nbsp; attr["ZONE_"] = feature.attributes.ZONE_;
&amp;nbsp;&amp;nbsp; attr["FSR"] = feature.attributes.FSR;
&amp;nbsp;&amp;nbsp; var geometry = new Polygon(feature.geometry);
&amp;nbsp;&amp;nbsp; var graphic = new Graphic(geometry);
&amp;nbsp;&amp;nbsp; graphic.setAttributes(attr);
&amp;nbsp;&amp;nbsp; ufmData.push(graphic);
&amp;nbsp; });
&amp;nbsp; featureLayer.applyEdits(ufmData, null, null, addSucceeded, addFailed);
&amp;nbsp; console.log(featureLayer);
 }

 function requestFailed(error) {
&amp;nbsp; console.log(error);
 }

 function addFailed(error) {
&amp;nbsp; console.log(error);
 }

 function addSucceeded() {
&amp;nbsp; console.log("add succeeded");
 }

&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks very much for any help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ed&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Feb 2014 23:04:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/feature-layer-created-from-json-not-drawing/m-p/618617#M57833</guid>
      <dc:creator>EdSaunders</dc:creator>
      <dc:date>2014-02-04T23:04:25Z</dc:date>
    </item>
  </channel>
</rss>

