调用 Portal 中 WebMap 并显示图例

通过3.x的api调用webmap,并显示图例
已邀请:

邵明升

赞同来自: fengye

【解决办法】:
用户使用的3.x的api,想调用WebMap,并显示图例

 【解决方案】: 

require([ 
"esri/map", 
"esri/arcgis/utils", 
"esri/dijit/Legend", 
"dojo/domReady!"], function(Map, arcgisUtils,Legend) { 
arcgisUtils.arcgisUrl = " https://sms.esrichina.com/port ... 3B%3B 
arcgisUtils.createMap("f6caf2ca33fc46d6b53bcd9c7f099791", "mapDiv").then(function (response) { 
map = response.map; 
var legend = new Legend({ 
map: map, 
layerInfos:(arcgisUtils.getLegendLayers(response)) 
}, "legendDiv"); 
legend.startup(); 
}); 
});

需要定义一个div,id=“legendDiv”,并且要设置样式 
#legendDiv{ 
background-color: #fff; 
position: absolute !important; 
z-index: 99; 
top:10px; 
right:20px; 
}  
 

要回复问题请先登录注册