Sunday 13 January 2019

javascript - Identify all layers on the map without pre-designing the infoWindow


This applies to the ArcGIS Server JavaScript API 2.4.


The Identify Task sample shows how IdentifyTask can be used to find features in multiple layers, as specified in the IdentifyParameters:


identifyParams.layerIds = [0,2];


In this sample, the infoWindow already contains elements for the expected layers, which are used to display multiple features in separate tabs of the infoWindow:








//In the JavaScript:
dijit.byId("bldgTab").setContent(layerTabContent(bldgResults,"bldgResults"));
dijit.byId("parcelTab").setContent(layerTabContent(parcelResults,"parcelResults"));


Is there a way to handle this dynamically, and create the required tabs at run-time?


For example, I wish to run IdentifyTask on all visible layers, and return the results in a separate tab of the infoWindow. How can I create the tabs dynamically?



Answer



Yes, this is possible. To create your tabs dynamically, look at creating dojo dijits programmatically vs. declaratively. When your visible layers change, modify your tab container to remove or add the appropriate tabs.


Edit: here's a proof of concept on JS Fiddle: http://jsfiddle.net/swingley/wKue4/ It doesn't really handle attributes but lets you select which layers to identify and builds the info window content dynamically.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...