renderers
require(["esri/renderers"], function(renderers) { /* code goes here */ });
Object:
esri/renderers
Since: ArcGIS API for JavaScript 4.8
A convenience module for importing Renderer classes when developing with TypeScript. For example, rather than importing renderers one at a time like this:
import ClassBreaksRenderer = require("esri/renderers/ClassBreaksRenderer");
import HeatmapRenderer = require("esri/renderers/HeatmapRenderer");
import SimpleRenderer = require("esri/renderers/SimpleRenderer");
import UniqueValueRenderer = require("esri/renderers/UniqueValueRenderer");
You can use this module to import them on a single line:
import { ClassBreaksRenderer, HeatmapRenderer, SimpleRenderer, UniqueValueRenderer } from "esri/renderers";
This module also allows you to implement type guards on geometries, making your code smarter.
import { Renderer } from "esri/renderers";
function logRenderer(renderer: Renderer): void {
if (renderer.type === "simple") {
// new at 4.8, the compiler knows the renderer is a SimpleRenderer
console.log("renderer symbol: ", renderer.symbol);
}
else {
if (renderer.type !== "heatmap") {
// the compiler knows the renderer must be a `ClassBreaksRenderer | UniqueValueRenderer`
console.log("renderer background symbol: ", renderer.backgroundFillSymbol);
}
}
}
Loading...