用于导入渲染器类的便捷模块,可用于在使用 TypeScript 开发时渲染 ImageryLayer。例如,不是像这样一次导入一个渲染器:
import FlowRenderer from "geoscene/renderers/FlowRenderer";
import ClassBreaksRenderer from "geoscene/renderers/ClassBreaksRenderer";
import UniqueValueRenderer from "geoscene/renderers/UniqueValueRenderer";
import RasterStretchRenderer from "geoscene/renderers/RasterStretchRenderer";
import RasterColormapRenderer from "geoscene/renderers/RasterColormapRenderer";
import RasterShadedReliefRenderer from "geoscene/renderers/RasterShadedReliefRenderer";
import VectorFieldRenderer from "geoscene/renderers/VectorFieldRenderer";
您可以使用此模块将它们导入到一行上:
import { FlowRenderer, ClassBreaksRenderer, UniqueValueRenderer, RasterColormapRenderer, RasterStretchRenderer, RasterShadedReliefRenderer, VectorFieldRenderer } from "geoscene/rasterRenderers";
此模块还允许您在呈现器上实现类型保护,从而使代码更加智能。
import { Renderer } from "geoscene/rasterRenderers";
function logRenderer(renderer: RasterStretchRenderer): void {
if (renderer.type == "raster-stretch") {
console.log("renderer color ramp: ", renderer.colorRamp);
}
}