FeatureLayer is not loading 4.19 and 4.20

341
4
08-03-2021 11:53 PM
nidaaktan
New Contributor II

Hi,

I'm trying to create FetureLayer using client-side graphics. here is my code;

 var layernew FeatureLayer({
 

          source: graphics,
          objectIdField: 'objectid',
          fields: [{ name: "objectid", type: "string" }],
          popupEnabled: true,
          popupTemplate: { content: "<div>Test Popup</div>" },
         
          renderer: {
            type: 'simple',
            symbol:{
              type: "simple-fill",
            color: [ 51,51, 204, 0.9 ],
               style: "solid",
           outline: { color: "white", width: 1 }
        },
          },
          editingEnabled: false,

        });
map.add(layer);
 
I can add layer to map but it is not show on map.I'm trying to run layer.load() function but function promise is definitely not resolved or reject.Featurelayer loadStatus property stay as 'loading'.
Is there anyone who can help me?
Thanks
0 Kudos
4 Replies
MichaelK1
New Contributor

Are you rendering 2D polygons ? Or Points? 
https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html

Can you share a snippet of your graphics?

Is there any reason why typing ObjectID as a string and not type: "oid"

0 Kudos
nidaaktan
New Contributor II

I'm rendering 2D polygons. I have no reason to type objectid as a string, i changed it to 'oid' but nothing changed, still not working. 

The code i shared works version 4.18 

I'll share  a snippet of my graphics.

0 Kudos
nidaaktan
New Contributor II

here is sample code

Is there any problem with symbol? I really can't understand.

0 Kudos
UndralBatsukh
Esri Regular Contributor

Hi there, 
Your codepen has an issue. You are directly assigning the symbol the layer's renderer. If you open the console you will see the error. Here is your codepen app updated. 

The changes are: 

const renderer = {
  type: "simple",
  symbol: symbol
};

var fl = new FeatureLayer({
   source: features,
   renderer: renderer, // change this from symbol to renderer
   ...
});

 

Hope this helps,

-Undral

0 Kudos