我有这个简单的函数javascript函数,可以根据传递的参数动态生成arcgis映射。该功能运行良好,但不会刷新图例。
我尝试清除legendDiv,附加它,在此函数加载之前使用jQuery进行前置,但它只加载空白但是现在代码仍然存在,尽管地图因此响应发生变化,旧的图例仍然存在。
function generate_map(xmin, ymin, xmax, ymax, wkid, graphic)
{
$j("#mapDiv").empty();
var map,
webmapId = graphic;
require([
"esri/map",
"esri/arcgis/utils",
"esri/dijit/Legend",
"esri/dijit/HomeButton",
"esri/dijit/Print",
"esri/tasks/geometry",
"dojo/domReady!"], function (Map, arcgisUtils, Legend, HomeButton) {
arcgisUtils.createMap(webmapId, "mapDiv", {
mapOptions: {
extent : new esri.geometry.Extent({
"xmin": xmin,
"ymin": ymin,
"xmax": xmax,
"ymax": ymax,
"spatialReference": {
"wkid": wkid
}
})
}} ).then(function (response) {
map = response.map
var legend = new Legend({
map: map,
layerInfos:(arcgisUtils.getLegendLayers(response))
}, "legendDiv");
legend.refresh();
var home = new HomeButton({
map: map
}, "HomeButton");
home.startup();
});
});
}
答案 0 :(得分:0)
将autoUpdate:true
属性添加到图例对象。