08-22-2018 10:21 PM - edited 08-22-2018 10:23 PM
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.
Solved! Go to Solution.
08-24-2018 12:33 AM
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 });
08-24-2018 07:04 AM - edited 08-29-2018 10:33 AM
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
08-29-2018 10:40 AM
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
08-29-2018 11:52 PM
You must know some parameters for the legend that you want to find, these are typical options:
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);