ArcGIS API for JS4.7加载ArcGIS Server发布的地形

ArcGIS Server如何发布地形------ArcGIS Server10.5发布在线dem高程服务

ArcGIS API for JS4.7加载上一篇博文中发布的地形十分简单,代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>三维测试</title>
    <link type="text/css" rel="stylesheet" href="http://localhost/arcgis/esri/css/main.css"/>
    <script src="http://localhost/arcgis/init.js"></script>
    <style>
        html,
        body,
        #viewDiv {
            padding: 0;
            margin: 0;
            height: 100%;
            width: 100%;
        }
    </style>
</head>
<body>
<div id="viewDiv"></div>
<script>
    require(["esri/Map",
        "esri/Ground",
        "esri/layers/ElevationLayer",
        "esri/config",
        "esri/views/SceneView",
        "esri/geometry/Extent",
        "dojo/domReady"
    ], function (Map,
                 Ground,
                 ElevationLayer,
                 esriConfig,
                 SceneView,
                 Extent
                 ) {
        esriConfig.request.corsEnabledServers.push("localhost:6443");//设置地图服务器已允许跨域
        var customElevation = ElevationLayer({
            url: "https://localhost:6443/arcgis/rest/services/dem/zz_30_dem/ImageServer"
        });
        var map = new Map({
            // basemap: "streets",//ESRI提供的底 图
            basemap: "hybrid",//ESRI提供的影像图
            //  ground: "world-elevation"//ESRI提供的全球地形
            ground: new Ground({
                layers: [ customElevation ]
            })
        });

        var view=new SceneView({
            map:map,
            container: "viewDiv"
        });
        view.ui.remove("attribution");//移除底部ESRI logo

        view.when(function () {
            view.goTo({
                position: {
                    x: 113.642578125,
                    y: 34.7222900390625,
                    z: 700,
                    spatialReference: {
                        wkid: 4326
                    }
                },
                heading: 50,
                tilt: 80
            }, {
                speedFactor: 0.7
            });
        }).catch(function (reason) {
            console.log(reason)
        });
    })
</script>
</body>
</html>

最后的结果预览

猜你喜欢

转载自blog.csdn.net/GISuuser/article/details/81118938