-
-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does legend widget work for map service beside feature service? #659
Comments
@JudyZhou The Legend widget is an Esri widget not a CMV widget. The layers that are supported by that widget are listed in the documentation. I'm not sure why that widget behaves the way it does but for what its worth, there have been a few other comments recently about that Esri Legend widget not properly updating and reflecting the state of the map. |
@tmcgee thanks for the help. I found that even the demo from this website http://demo.cmv.io/viewer, when I check/uncheck layers in dynamic map service Louisville Public Safety/Public Safety or Louisville Public Safety/Emergency Operations, the legend doesn't update, but when uncheck and check again top level service name Louisville Public Safety, then the legend update. Legend widget doesn't have issue with ESRI Web AppBuilder though. Please check. |
@JudyZhou Its true, the web app builder does update the legend when layers and sublayers are toggled. Web app builder's layer control and legend widget are dependent on the web app builder framework though, so if you'd like to use those widgets you would need to set up web app builder's files in cmv, and use @tmcgee 's web app builder mixin for cmv. |
Does a new CMV widget like below solve the issue(s)? 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();
}));
this._started = true;
}
});
}); |
Looks like that would work. I'm guessing update end fires when any layer is updated also? |
That is exactly what the event is for. Per the API docs |
I've just tested it in the develop branch. It works. I can make a pull request. |
@JudyZhou when you get a chance to test the widget out, please let us know if it fixes your issue. |
new core CMV Legend widget added in #660 |
My viewer uses map service, not feature service. The legend does not work in a proper way. legend panel only display legend for default layers turned on at initial time. When I turn on/off layers the legend doesn't change accordingly. Please help!
The text was updated successfully, but these errors were encountered: