Answers:
Map类的API参考说明以下内容:
以下是有效选项:“街道”,“卫星”,“混合”,“地形”,“灰色”,“海洋”,“国家地理”,“ osm”。从3.3版本开始
相反,您应该只定义一个新的ArcGIS Tiled Map Service图层并按以下方式使用它:
var baseMapLayer = new esri.layers.ArcGISTiledMapServiceLayer("your URL");
map.addLayer(baseMapLayer);
对于arcgis javascript SDK 3.x版,您可以使用esri / basemaps类来声明和注册自定义底图并与您的地图一起使用:https : //developers.arcgis.com/javascript/3/jsapi/esri.basemaps-amd.html
声明并注册自定义底图:
Basemaps.mybasemap = {
title: 'My custom basemap',
thumbnailUrl: 'https://js.arcgis.com/3.22/esri/images/basemap/satellite.jpg',
//itemId: 'ulas',
baseMapLayers: [
{ url: "https://services.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer" }
]
};
在地图构造函数中使用自定义底图:
var map = new Map("mapDiv", {
basemap: "mybasemap",
center: [-122.69, 45.52],
zoom: 3
});
或者,您可以将自定义底图应用于现有地图:
map.setBasemap("mybasemap");
完整的代码示例:https : //codepen.io/digz6666/pen/wPwPbW
对于arcgis javascript SDK版本4.x,可以使用esri / Basemap。
声明基础地图图层和基础地图:
var baseLayer = new MapImageLayer({
url: "https://services.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer"
});
var myBasemap = this.esri.basemap({
baseLayers: [baseLayer],
title: 'My custom basemap',
id: 'my_custom_basemap'
});
将底图应用于现有地图对象:
map.basemap = myBasemap;
您不必指定内置底图。像这样将您的自定义底图添加为图层。
var map;
require(["esri/map", "esri/layers/ArcGISTiledMapServiceLayer", "dojo/domReady!"],
function (Map, ArcGISTiledMapServiceLayer ) {
map = new Map("map", {
center: [-76.756, 40.241],
zoom: 8
});
var customBasemap = new ArcGISTiledMapServiceLayer(
"http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer");
map.addLayer(customBasemap);
});