arcgis for js 4.x (动态服务加载MapImageLayer)
<html> <head> <meta charset="utf-8" /> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" /> <title>地图加载</title> <style> html, body, #viewDiv { padding: 0; margin: 0; height: 800px; width: 800px; overflow: hidden; } </style> <link rel="stylesheet" href="https://js.arcgis.com/4.23/esri/css/main.css" /> <script src="https://js.arcgis.com/4.23/init.js"></script> <script> require(["esri/Map", "esri/views/MapView", "esri/layers/MapImageLayer", ], function( Map, MapView, MapImageLayer, ) { var map = new Map({ //basemap: 'osm' }); var view = new MapView({ container: "viewDiv", map: map, }); let layer = new MapImageLayer({ url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer" }); map.add(layer); }); </script> </head> <body class="calcite"> <div id="viewDiv"></div> </body> </html>