Skip to content

Instantly share code, notes, and snippets.

@ssylvia
Created July 14, 2016 21:07
Show Gist options
  • Save ssylvia/76a6c09d616531ac9441c06ce843a2fa to your computer and use it in GitHub Desktop.
Save ssylvia/76a6c09d616531ac9441c06ce843a2fa to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>Load a basic WebMap - 4.1</title>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<link rel="stylesheet" href="https://jsdev.arcgis.com/4.1/esri/css/main.css">
<link rel="stylesheet" href="https://jsdev.arcgis.com/4.1/esri/css/calcite/calcite.css">
<script src="https://jsdev.arcgis.com/4.1/"></script>
<script>
require([
"esri/views/MapView",
"esri/WebMap",
"dojo/domReady!"
], function(
MapView, WebMap
) {
/************************************************************
* Creates a new WebMap instance. A WebMap must reference
* a PortalItem ID that represents a WebMap saved to
* arcgis.com or an on-premise portal.
*
* To load a WebMap from an on-premise portal, set the portal
* url in esriConfig.portalUrl.
************************************************************/
var webmap = new WebMap({
portalItem: { // autocasts as new PortalItem()
id: "f2e9b762544945f390ca4ac3671cfa72"
}
});
/************************************************************
* Set the WebMap instance to the map property in a MapView.
************************************************************/
var mapView = new MapView({
map: webmap,
container: "viewDiv"
}).then(function(view) {
setTimeout(function(){
view.destroy();
webmap.destroy();
console.log('destroyed');
},4000);
});
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment