Skip to content

Commit

Permalink
Merge pull request #660 from roemhildtg/fix-legend-layer-visibility
Browse files Browse the repository at this point in the history
FIX: update legend when maps `update-end` event is fired
  • Loading branch information
tmcgee authored Jan 10, 2017
2 parents f636350 + e4b3c5b commit 3d20129
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion viewer/js/config/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ define([
include: true,
id: 'legend',
type: 'titlePane',
path: 'esri/dijit/Legend',
path: 'gis/dijit/Legend',
title: i18n.viewer.widgets.legend,
open: false,
position: 1,
Expand Down
31 changes: 31 additions & 0 deletions viewer/js/gis/dijit/Legend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
define([
'dojo/_base/declare',
'dijit/_WidgetBase',
'dojo/_base/lang',
'esri/dijit/Legend'
], function (
declare,
_WidgetBase,
lang,
Legend
) {
return declare([_WidgetBase], {
startup: function () {
this.inherited(arguments);

this.legend = new Legend({
arrangement: this.arrangement || Legend.ALIGN_LEFT,
autoUpdate: this.autoUpdate || true,
id: this.id + '_legend',
layerInfos: this.layerInfos,
map: this.map,
respectCurrentMapScale: this.respectCurrentMapScale || true
}, this.domNode);
this.legend.startup();

this.map.on('update-end', lang.hitch(this, function () {
this.legend.refresh();
}));
}
});
});

0 comments on commit 3d20129

Please sign in to comment.