Hexagon Geospatial

Developer Discussions

Discuss topics with other Hexagon Geospatial Power Portfolio developers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
Regular Contributor
Posts: 190
Registered: ‎07-27-2016
Accepted Solution

Portal SDK $GP.legend.add

Hi Guys,


I am adding a legend entry from a WFS service with the name attribute to set the layer name that works well.

But the features just gets added to category list un-categorized at the bottom of the list.

Is there a way to create a category programatically and add these features to it?


I am using $GP.legend.add to add the legend and running portal sdk 16.2


Any help would be appreciated.


Kind Regards


Technical Evangelist
Posts: 130
Registered: ‎08-05-2015

Re: Portal SDK $GP.legend.add

Hi Jacques,


are these WFS legend items analyses? If yes, you could create your WFS category legend upfront using the Portal UI and then "update" the analyses instead of creating new ones.


Best regards,


Regular Contributor
Posts: 190
Registered: ‎07-27-2016

Re: Portal SDK $GP.legend.add

[ Edited ]

Hi Piotr,


Hope all is well.

No,it is not analyses.

I use the following to add the legend:


    successAfterRender: true,
    ids: [featureClassId],
    url: val_WFSURL,
    definitionName: "WFS",
    name: "My Personal Data"
}, function(result) {
    //turn off all layers in WFS
        function(item) {
                    id: item
                function(FinalResult) {
    //==LOAD TOOLS==


So the layer entry gets named "My Personal Data" but the features just gets added to the category tab in the buttom of the list.




Technical Evangelist
Posts: 130
Registered: ‎08-05-2015

Re: Portal SDK $GP.legend.add



There is no API for manipulating the legend categories panel... But maybe we could achieve your goal in another way?


From the code above I see that after adding WFS layers to the legend you are hiding them.


I asked about analyses because it is possible to update an existing analysis (so that the map layer is altered). So maybe you could pregenerate your desired layout of the category control and the legend items in the Portal GUI, and then instead of removing/adding the layers you could update them (or also show&hide)?




Do you need immediate support?
Please submit a Ticket through our
Development Ticket Portal.