###Add a Scene Layer to a 3D map
This lab covers the basics of adding a scene layer to your application.
To learn more about what options you have with SceneLayers look at the SceneLayer API Reference
-
Click create_starter_map_3d/index.html and copy the contents to a new jsbin.com.
-
In
JSBin>HTML, update therequirestatement andfunctiondefinition:
require([
"esri/Map",
"esri/views/SceneView",
"esri/layers/SceneLayer",
"dojo/domReady!"
], function(Map, SceneView, SceneLayer) {- Now let's add the buildings scene layer to the map:
var buildingsSL = new SceneLayer({
url: "https://tiles.arcgis.com/tiles/hRUr1F8lE8Jq2uJo/arcgis/rest/services/BuildingsDC/SceneServer/layers/0"
});
var map = new Map({
basemap: "dark-gray-vector",
layers: [buildingsSL],
ground: "world-elevation"
});-
The JSBin
Outputpanel should show a 3D view of earth that you can rotate around and zoom in on DC to see the 3D buildings. -
Since we are focused on DC, modify the SceneView to be zoomed in more and tilt the scene since we are looking at 3D data. Take a look at the SceneView and the Camera
var view = new SceneView({
container: "viewDiv",
map: map,
camera:{
position: [-77.04, 38.86, 790],
tilt: 71.47,
heading: 30.25
}
});Your app should look something like this:
###Bonus
- Add the same layers you did in the 2D map, MetroLines, BlockGroups, and MetroStations You can see the resulting code here