/** * This object contains helper methods for generating popup templates to be set on * a [layer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#popupTemplate). The suggested popup templates * will only include information in the popup related to the layer's renderer. For example, the * popup template in the image below was generated based on a layer rendered with a * [predominance](https://developers.arcgis.com/javascript/latest/references/core/smartMapping/renderers/predominance/) renderer coloring * census tracks based on the decade in which the most homes were built. * * This provides a better default popup template than the traditional approach of providing a long table of unformatted values. * * Suggested default template based on renderer | Traditional default * -----|---------- * [![popup-sm-default](https://developers.arcgis.com/javascript/latest/assets/references/core/smartMapping/popup-sm-default.png)](https://developers.arcgis.com/javascript/latest/sample-code/visualization-sm-predominance/) | ![popup-default](https://developers.arcgis.com/javascript/latest/assets/references/core/smartMapping/popup-default.png) * * @since 4.16 * @see [Sample - Generate a predominance visualization](https://developers.arcgis.com/javascript/latest/sample-code/visualization-sm-predominance/) * @see [Sample - Generate a dot density visualization](https://developers.arcgis.com/javascript/latest/sample-code/visualization-sm-dotdensity/) */ import type { RendererUnion } from "../../renderers/types.js"; import type { PopupSupportedLayer } from "../types.js"; import type { Templates } from "./types.js"; /** * Returns one or more suggested [popupTemplates](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/) for a given layer based on * its renderer. This method is useful in apps where a layer's renderer can be modified by the user (or some other process) * and the popup template is expected to display values related to the renderer. Popup templates will not * be generated for layers with renderers that don't refer to a data value (i.e. SimpleRenderer with no visual variables). * * @param params - The function parameters. * @returns Returns an object containing suggested primary * and secondary PopupTemplates for the input layer. * @example * // Sets a suggested popupTemplate on the layer based on its renderer * popupTemplateCreator.getTemplates({ * layer: featureLayer, * renderer: featureLayer.renderer * }).then(function(popupTemplateResponse){ * if ( popupTemplateResponse.primaryTemplate ){ * featureLayer.popupTemplate = popupTemplateResponse.primaryTemplate.value; * } * }).catch(function(error){ * console.error(error); * }); */ export function getTemplates(params: TemplateParameters): Promise; export interface TemplateParameters { /** The layer to which the suggested popup templates can be applied. */ layer: PopupSupportedLayer; /** * Specify the renderer to be used on the layer when * if it will be different than the renderer already set on the layer. */ renderer?: RendererUnion; }