Skip to content

Commit

Permalink
FIX: update legend when maps update-end event is fired
Browse files Browse the repository at this point in the history
 - adds new gis/dijit/Legend widget from #659
 - fixes #340
 - fixes #294
  • Loading branch information
green3g committed Jan 10, 2017
1 parent 42356d0 commit d42140a
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 d42140a

Please sign in to comment.