Hello,
I have been tasked at work to learn all things API. I have a little bit of a python background (ArcPy primarily), I'm pretty GIS competent, and have been working in AGOL for 1 year. Seems like Esri has provided a great framework to get started with APIs. However, I am struggling a little bit. For this API, I am using API for JavaScript, and am writing the code using the HTML, I am following the tutorials through CodePen.
I am working through the tutorials, I am to the point where I want to use the CodePen and display one of my configured web maps. I followed the tutorial, I created my APIKey, I have my PortalID of the map I want to display. I enabled all options in location services just to cover all bases. I cannot get it to work and I'm at a loss at this point.
tutorial I followed: display-a-web-map
I have tried typing the code out from scratch (minus the APIKey, PortalID - those I'll still copy/paste), I have tried copy/pasting everything and replacing with my APIKey, my PortalID. I have scanned through about 100 times and I don't see any typos. I've pasted what I've typed out below. I replaced my API Key and PortalID with dummy values for security.
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Lumen Web Map</title>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<link rel="stylesheet" href="https://js.arcgis.com/4.19/esri/themes/light/main.css">
<script src="https://js.arcgis.com/4.19/"></script>
<script>
require([
"esri/config",
"esri/WebMap",
"esri/widgets/MapView",
"esri/widgets/ScaleBar",
"esri/widgets/Legend"
], function (esriConfig, WebMap, MapView, ScaleBar, Legend) {
esriConfig.apiKey = "api key";
const webmap = new WebMap({
portalItem: {
id: "portal id"
}
});
const view = new MapView({
container: "viewDiv",
map: webmap
});
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
Is there some typo I'm just not seeing? Is there some setting I don't know about? Is there some setting on my Web Maps or layers I don't know about?
I've been stuck on this tutorial for two days and I am truly stuck and don't know how to move forward.
Any help would be greatly appreciated!!
Thanks!