操作方法
使用矢量底图的优点之一是底图的样式(如颜色)可使用 ArcGIS API for JavaScript 进行自定义。
可以通过获取样式 URL 并将其应用于代码来更改矢量底图的样式。
require(["esri/map", "esri/layers/FeatureLayer", "esri/layers/VectorTileLayer", "dojo/domReady!" ], function (Map, FeatureLayer, VectorTileLayer) { //Initializing the map constructor var map = new Map("map", { center: [-118, 34.5], zoom: 8, //basemap: "topo" }); //自定义矢量底图时,将 URL 更改为自定义 URL。 var darkGrayStyleURL = "https://www.arcgis.com/sharing/rest/content/items/57436c01bc754dbb87dfb636b6484022/resources/styles/root.json"; var lightGrayStyleURL = "https://www.arcgis.com/sharing/rest/content/items/1e47168d181248e491541ffd5a91c0de/resources/styles/root.json" let vectormap = new VectorTileLayer("https://basemaps.arcgis.com/v1/arcgis/rest/services/World_Basemap/VectorTileServer"); vectormap.setStyle(lightGrayStyleURL); vectormap.on("load", () => { map.addLayer(vectormap); }); });
获取来自 ArcGIS 专家的帮助
下载 Esri 支持应用程序