Select to view content in your preferred language

Setting up codesandbox with @arcgis/core

3760
11
Jump to solution
04-15-2021 11:23 AM
SethLutske
Occasional Contributor

I'm trying to set up a simple template using codesandbox to be able to spin up arcgis js api maps quickly.  I dont like codepen as much as codesandbox.  I'd like to do it with the newer es6 module imports.  I added @Anonymous User/core to the dependencies, and in my js file I have this:

 

import Map from "@arcgis/core/Map";
import MapView from "@arcgis/core/views/MapView";
import "@arcgis/core/assets/esri/themes/dark/main.css";

const map = new Map({
  basemap: "dark-grey"
});

const view = new MapView({
  map,
  container: "viewDiv",
  zoom: 4,
  center: [15, 65]
});

 

Unfortunately I'm getting the error:

Cannot read property 'zoomIn' of null
 
I tried using the `ncp` script under the copy assets section of the docs , but that makes no difference.  If you close the error overlay, you can see that the map container does seem to render, but no map is in there.
 
 
What simple thing am I missing here? 
0 Kudos
11 Replies
ReneRubalcava
Esri Frequent Contributor

Currently, no. There is no fix.

 

But, based on this comment here, this will work in an upcoming release of Parcel, so eventually should work in codesandbox down the road.

0 Kudos
PatrickMcKinney99
Regular Contributor

I can confirm that by using the @parcel/bundler-experimental and versions of @parcel/core and parcel mentioned on the GitHub issue, I was able to generate a build in parcel.js using ESM modules and JS API.

0 Kudos