怎样加载arcgis 切片服务,加载切片服务使用的是"esri/layers/TileLayer" 接口
填写好服务地址比如服务"https://services.arcgisonline.com/arcgis/rest/services/World_Terrain_Base/MapServer" 和坐标系 wkid: 102100,再通过map.add()方法把服务添加到map对象中去渲染。
注意:请求本地切片服务,如果你的arcgisserver版本低于10.3可能会有服务跨域的情况,解决方案1,请求服务时候设置代理 2,将arcgisserver设置为允许跨域 参考地址 https://blog.csdn.net/u012123612/article/details/53638537
代码
require(["esri/Map",
"esri/views/MapView",
"esri/layers/TileLayer"
], function (Map, MapView, TileLayer) {
let url = "https://services.arcgisonline.com/arcgis/rest/services/World_Terrain_Base/MapServer";
let spatialReference = {
wkid: 102100
}
var map = new Map(
);
var view = new MapView({
container: "map",
map: map,
});
addTileLayer(url, spatialReference);
function addTileLayer(url, spatialReference) {
var layer = new TileLayer({
url: url,//服务地址
spatialReference: spatialReference,//坐标系
})
map.add(layer);
}
})
效果