Is is possible to add a service in legend without adding it as layer in Web Appbuilder (local layer) or ArcGIS Portal map?
Shazia, it may help to explain the use case for this. Are you just wanting a graphic of a layer in your legend without it ever drawing or without any access to the data? I'm not sure that I understand the need for this.
With that said, I probably wouldn't bee the one that could answer this, but it may help others to know more information.
A case i can imagin:
If you add a Stream Layer to a WebMap it only supports a simple renderer. If you want e.g. a unique value renderer you have to implement it by yourself. In this case you also need to modify the Legend and Layerlist.
Thanks for the reply.
We have a tiled service called FSM used as a basemap in Portal web map.
That webmap is used in Web appbuilder. We want to show its legend in the application when that basemap is selected.When we switch to imagery basemap, FSM basemap legend shall not be displayed.
The Legend dijit respect the layer visibility on the map. Therefore, if you just hide the FSM layer it should not be visible on the legend. The layer will NOT be removed from the map it will just be hidden.
Layer.visible = false;
Are you using the AGOL version or are you using the develop edition of WAB?
if the dev edition, I would take a look at the custom widget Enhanced Basemap Gallery Widget 1.3 - 12/14/2015 and some of the other custom widgets available Web AppBuilder Developer Edition - Customization Resource List
But as Girish mentioned, the legend should respect the layers you have visible.
Could you have your JS code simply insert another row into the Legends Div with the Icon and Label you want?
Well, if the aim is to show just the legend (as a picture or table or any kind of html element) in the legend widget, then sure, one can just add it as another div section to the widgets\Legend\Widget.html file.