3D maps are also called scenes.
From the previous article,
The first argument to the Require entry function is a string array
["Esri/map", "Esri/views/mapview", "dojo/domready!"]
Here, Mapview is the map view of 2D.
So, to change the map to 3D map, it is very simple, just need to change the string array of the second reference to "Esri/views/sceneview"
Then modify the corresponding view code in the second parameter.
A new code for the second parameter (function) is given below
function (map, Sceneview) { varnew Map ({ "OSM", "world-elevation " });//still using the OSM base map varnew Sceneview ({" Viewdiv " , Map:map, 50000000, Center: [113.5, +] });//scale 1:50 million}
As you can see here, the View object is not the Mapview class, but the Sceneview class.
And there's a new thing--ground in the Map object constructor.
Here is the ground information:
The ground property is surface data, which can be an instance of the ground class.
The following is the Sceneview class information:
Sceneview and Mapview also inherit from the view class. Sceneview
In the same way, give the full HTML code:
<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><Metaname= "Viewport"content= "initial-scale=1, maximum-scale=1, User-scalable=no"><title>Get started with sceneview-create a 3D map</title><style>html, body, #viewDiv{padding:0;margin:0;Height:100%;width:100%; }</style><Linkrel= "stylesheet"href= "Https://js.arcgis.com/4.2/esri/css/main.css"><Scriptsrc= "HTTPS://JS.ARCGIS.COM/4.2/"></Script><Script>require (["Esri/map", "Esri/views/sceneview", "dojo/domready!"], function(Map, Sceneview) {varMap= NewMap ({basemap:"OSM", Ground:"world-elevation" }); varView= NewSceneview ({container:"Viewdiv", Map:map, scale:50000000, center: [113.5, -] });});</Script></Head><Body> <DivID= "Viewdiv"></Div></Body></HTML>
Show Map
The running success is probably like this (slightly modified scale of 150,000, coordinates of 114.3 and 30.5 Yes, it is Wuhan)
PS: If you feel like a plane can be the scale back to 500w or 1000w, the ground fluctuation is not obvious can be adjusted basemap for other maps, coordinates to the mountains.
ArcGIS API for JavaScript 4.2 study notes [2] Show Map