Error adding graphicslayer to map (@arcgis/core 4.20)

543
2
09-09-2021 01:27 AM
FreddyBroring
New Contributor III

Hi,

I'm getting an error when adding a graphiclayer to the map with view.map.add(graphiclayer). When I use view.map.addMany([graphiclayer]) the error doesn't show up.

The console error is:

[esri.support.LayersMixin] #add() The item being added is not a Layer or a Promise that resolves to a Layer.

import GraphicsLayer from '@arcgis/core/layers/GraphicsLayer';
 
const gl = new GraphicsLayer()
view.map.add(gl);   ===> error
 
Is this a bug or is it me doing something wrong?
Tags (1)
0 Kudos
2 Replies
RitikaManderwal
New Contributor III

hi,

i think you need not to write view.map.add(gl) instead of this you can directly do map.add(gl)

0 Kudos
FreddyBroring
New Contributor III

Thanks for the suggestion, but the map is a property of the MapView and is an instance of Map. 

0 Kudos