10-23-2017 07:17 PM - edited 10-23-2017 07:34 PM
I have a main legend and then various custom queries that add new legends with one entry to the legend display.
I came up with the code below to remove these custom queries but leave the main legend displayed:
var ii = 0;
$GP.legend.find({}, function (ret) {
ii = 0;
ret.legendItems.forEach(function (item) {
ii += 1;
if (ii>71)
{ret.legendItems.slice(ii)[0].remove();
}
});
The first time i run this code all the queriy legends are successfully removed and the main legend is not. But subsequent tries to run additional queries are unsuccessfull - no legend is added and the query results are not displayed on the map.
****Important Note***
I find that if I delete the legend added by running the query using "Remove" (right mouse click while pushing on upside down black triangle) the same problem occurs - in this case i am using no custom code to remove the legend entry.
What is the correct way to remove all legends but the default legend (which has 71 entries in it) and beable to have them add back when a new query (same query name, different selection) is run. For example the "Address #" query finds all addresses with address "300", then remove the legend for it which also removes the map display, and then later run the query again but with address "400"
10-24-2017 01:25 AM
Hi Jane,
Regarding the impossibility of removing legend entries using GUI - I cannot reproduce that on normal or SDK Portal instance. I tried queries created both from GUI and from the code. The Remove button worked fine.
It could be some customization part, breaking the Portal behavior.
Thanks,
Jan
10-24-2017 08:22 AM
10-24-2017 09:09 AM
function FindbyOwner(owner) { document.getElementById('dialogbox').style.display = "none"; document.getElementById('dialogoverlay').style.display = "none"; iicount + iicount + 1; var queryName2 = "Owner_" + owner; qName = "Owner"; queryName2 = qName; // queryname is just "Owner" style4 = new Intergraph.WebSolutions.Core.WebClient.Platform.Style.AreaStyle(null, { styles: [{ type: "SimpleLineStyle", color: "#00ff00", width: 3 }, { type: "SimpleFillStyle", // color: "#00ff00", // translucency: 0.7, translucency: 1.0, color: "#ffffff" }] }); //findowners_list(); //$GP.ui.info("list of owners: " + a); owner = owner.replace("'", "''"); $GP.crs.setCurrent("EPSG:3436", function () { $GP.queries.add({ queryName: queryName2, featureClassId: "34644522FD66F454EFD7A34AC7AA1F373C41D430|Parcels_with_Labels", url: "http://cthse-gis/JD1/MapService.svc", applicationId: "JD1_GeomediaWebMap_Source", definitionName: "MapPublisher", style: style4, addToLegend: true, filters: [ { operator: "like", operands: ["Owner_Name", "*"+owner+"*"] }], }, function (result) { $GP.queries.find({ analysisId: result.analysisId, }, function (result2) { result2.analysis.addToDataView(), $GP.legend.find({ name: qName }, function (result) { //alert(result.legendItems.length); if (result.legendItems && result.legendItems.length > 0) result.legendItems[0].set_name("Owner Query"); }); }); }); }); }
10-24-2017 10:49 AM
10-24-2017 10:51 AM
10-24-2017 02:36 PM
10-25-2017 03:38 AM
Hi Jane,
If you wish to delete a query, you should use Analysis.remove(), then you should be able to overcome the issue with existing queryName
You can call this function
Jan
10-25-2017 08:46 AM