我本地发布好的地图服务信息如下图所示:
我们在代码中使用到的url是图中所示的REST URL
加载代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>Livalon</title>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style> <link rel="stylesheet" href="/plugins/arcgis_js_api/library/4.6/esri/css/main.css">
<script src="/plugins/arcgis_js_api/library/4.6/init.js"></script> <script>
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/MapImageLayer",
"dojo/domReady!"
], function(Map, MapView,MapImageLayer) {
var layer = new MapImageLayer({
url: "http://localhost:6080/arcgis/rest/services/chongren/MapServer"
});
var map = new Map({
});
map.add(layer);
var view = new MapView({
container: "viewDiv",
map: map
});
});
</script>
</head> <body>
<div id="viewDiv"></div>
</body>
</html>
之后就可以加载我们发布好的地图了!