Hexagon Geospatial
MENU

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 
Reply
Highlighted
Regular Contributor
Posts: 248
Registered: ‎05-01-2016
Accepted Solution

SDK legend - Can i "hide" a legend entry while still displaying the feature in map?

[ Edited ]

Is it possbile to turn off display of a legend entry (ie the row in the legend corresponding to a specific query)?.  When a user turns off the highlighting of  all elements of a feature via an interface i have created, the query has no elements so i would like to no longer have "HIghlight Query" displayed in legend.  When elements are again selected for highlighting (display in a different color from default for feature) I would like to turn the legend entry back on.  I am looking for a way to modify the legend itself like in GeoMedia where you can control whether or not the legend includes an entry for a feature which is displayed on the map but you might not want it in the legend (for example you don't want the line "Labels of River" or "Highway Shields" to display as a legend entry.

Technical Evangelist
Posts: 1,118
Registered: ‎09-11-2015

Re: SDK legend - Can i "hide" a legend entry while still displaying the feature in map?

Hi Jane, I think you will have to go through the DOM as I haven't found any LegendItem property or function which would return the DOM element ID.

$GP.legend.find({ /* provide search config here */ }, function (ret){
     // returned legend Item
     // expecting there's only ONE, otherwise foreach loop is needed
     var domSearch = "span:contains('" + ret.legendItems[0].get_name() + "')";
     $(domSearch)
       .closest("ul") // find closest legend main DOM element
       .toggle(); // toggle its visibility
});
Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Regular Contributor
Posts: 248
Registered: ‎05-01-2016

Re: SDK legend - Can i "hide" a legend entry while still displaying the feature in map?

[ Edited ]

Thanks very much - I will try it....ALso if i want to call two subroutines that run queries to highlight elements (in this case i am calling them to turn off all highlighting)

 

(   hiLiteRoad("1000000");

    hiLiteParcel("1000000");

)

This calls 2 subroutines that run queries for all roads (hiLiteRoad) with indexval=1000000 and all parcels (hiLiteParcel) with indexval=-1000000 so that no roads or parcels are highlighted  do i have to use  callbacks to prevent one query from being skipped....I don't care what order the queries are run, only that both are run - any tips how to do this very appreciated.

Thanks again,

Jane

Regular Contributor
Posts: 248
Registered: ‎05-01-2016

Re: SDK legend - Can i "hide" a legend entry while still displaying the feature in map?

Can you advise what goes here:

 

{ /* provide search config here */ },

 

The legend entry displays with name of "hilitedParcel"  at the bottom of the legend...if a query is also displayed then it will be second to last in the legend

 

There is only one legend entry i want to remove and it will always have the same name  

Technical Evangelist
Posts: 1,118
Registered: ‎09-11-2015

Re: SDK legend - Can i "hide" a legend entry while still displaying the feature in map?

You must know some parameters for the legend that you want to find, these are typical options:

  • name
  • id
  • legendItemId
  • etc...

Please perform few tests and it should be clear which parameter to use. The name could work. Related example is:

var legendInfo = "Legend Items: ";

$GP.legend.find({}, function (ret){
	ret.legendItems.forEach(function (item) {
        legendInfo += $GP.utils.sdump(item) + " ";
	});
});
$GP.ui.info(legendInfo);

 

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

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