Uncaught (in promise) TypeError: GraphicsLayer is not a constructor

1147
2
01-08-2020 10:22 AM
CamCode
New Contributor III
import Map from "esri/Map";import MapView from "esri/views/MapView";import Graphic from "esri/Graphic";import GraphicsLayer from "esri/layers/GraphicsLayer";import webMercatorUtils from "esri/geometry/support/webMercatorUtils"; async function kewlClickHandler(event) {     function initGo();         function initGo(Map, MapView, Graphic, GraphicsLayer, webMercatorUtils) {           const map = view.map;           var graphicsLayer = new GraphicsLayer(); // here          map.add(graphicsLayer);           ...... etc

No matter how I arrange my function params and header module includes; I repeatedly get the following error with my initDrawLine function:

Uncaught (in promise) TypeError: GraphicsLayer is not a constructor

New to arcgis-js-api, any ideas?

0 Kudos
2 Replies
Noah-Sager
Esri Regular Contributor

Hi Cam, I don't see anything obvious in the code you shared. What version of the API are you working with? Could you share a simple codepen that reproduces this issue?

0 Kudos
ChrisSmith7
Frequent Contributor

What happens if you change the imports to requires? E.g.:

const GraphicsLayer = require("esri/layers/GraphicsLayer");
0 Kudos