Hello all! This is my first post beyond my introduction.
I thought it would be good to see if I could convert my JavaScript code for the Display a Map tutorial from AMD to ESM. When it didn't work, I made an even simpler version -- which still doesn't work. <g>
This is the AMD version that works as-expected:
require([
"esri/config",
"esri/Map",
"esri/views/MapView"
], function(esriConfig, Map, MapView) {
esriConfig.apiKey = "not-my-actual-api-key";
// create basemap
const map = new Map({
basemap: "arcgis-navigation"
});
// set a map view
const view = new MapView({
map: map,
center: [-82.998794, 39.961176], // Columbus, Ohio 39.961176 / -82.998794
zoom: 9,
container: "viewDiv"
});
});
This is the ESM version that does not work:
import esriConfig from "@arcgis/core/config";
import Map from "@arcgis/core/Map";
import MapView from "@arcgis/core/views/MapView";
esriConfig.apiKey = "not-my-actual-api-key";
// create basemap
const map = new Map({
basemap: "arcgis-navigation"
});
// set a map view
const view = new MapView({
map: map,
center: [-82.998794, 39.961176], // Columbus, Ohio 39.961176 / -82.998794
zoom: 9,
container: "viewDiv"
});
Everything below the API code is the same, so I am supposing the trouble happens there or above. With that in mind, I was seeking an ESM example of config using the API key, but I could not find one. Also, I am supposing I shouldn't post my actual API key, so I removed that from both blocks of code.
What changes would fix the ESM code?