Created
January 4, 2018 00:57
-
-
Save aysark/f941cd85f8f104289a324729faa7ada4 to your computer and use it in GitHub Desktop.
DevLabs - Display a Web Map // source https://jsbin.com/zemolac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no"> | |
<title>DevLabs - Display a Web Map</title> | |
<style> | |
html, body, #viewDiv { | |
padding: 0; | |
margin: 0; | |
height: 100%; | |
width: 100%; | |
} | |
#titleDiv { | |
position: absolute; | |
width: 100%; | |
padding: 15px; | |
line-height: 1; | |
z-index: 1; | |
background: #fff; | |
font-family: "Avenir Next W00"; | |
font-size: 20px; | |
} | |
</style> | |
<link rel="stylesheet" href="https://js.arcgis.com/4.6/esri/css/main.css"> | |
<script src="https://js.arcgis.com/4.6/"></script> | |
<script> | |
require([ | |
"esri/WebMap", | |
"esri/views/MapView", | |
"esri/widgets/Legend", | |
"dojo/domReady!" | |
], function(WebMap, MapView, Legend) { | |
var webmap = new WebMap({ | |
portalItem: { | |
id: "da10cf4ba254469caf8016cd66369157" // This was created in the Create a web map lab | |
} | |
}); | |
var view = new MapView({ | |
container: "viewDiv", | |
map: webmap, | |
padding: {top: 50} | |
}); | |
// Challenge | |
webmap.then(function(map){ | |
document.getElementById("titleDiv").innerHTML = map.portalItem.title; | |
}); | |
var legend = new Legend({ | |
view: view | |
}); | |
view.ui.add(legend, "top-right"); | |
view.ui.add(new Locate({view: view}), "top-left"); | |
}); | |
</script> | |
</head> | |
<body> | |
<div id="titleDiv"></div> | |
<div id="viewDiv"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment