renderers

AMD: require(["geoscene/renderers"], (renderers) => { /* 代码 */ });
ESM: import * as renderers from "@geoscene/core/renderers";
对象: geoscene/renderers
起始版本: GeoScene API for JavaScript 4.22

一个方便的模块,用于在使用 TypeScript 进行开发时导入 Renderer 类。例如,而不是像这样一次导入一个渲染器:

import ClassBreaksRenderer from "geoscene/renderers/ClassBreaksRenderer";
import HeatmapRenderer from "geoscene/renderers/HeatmapRenderer";
import SimpleRenderer from "geoscene/renderers/SimpleRenderer";
import UniqueValueRenderer from "geoscene/renderers/UniqueValueRenderer";
import DictionaryRenderer from "geoscene/renderers/DictionaryRenderer";

您可以使用此模块在一行上导入它们:

import { ClassBreaksRenderer, HeatmapRenderer, SimpleRenderer, UniqueValueRenderer } from "geoscene/renderers";

此模块还允许您在呈现器上实现类型保护,从而使代码更智能。

import { Renderer } from "geoscene/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);
    }
  }
}

类型定义

ClassBreaksRenderer ClassBreaksRenderer

ClassBreaksRenderer。

DictionaryRenderer DictionaryRenderer

DictionaryRenderer。

DotDensityRenderer DotDensityRenderer

DotDensityRenderer。

HeatmapRenderer HeatmapRenderer

HeatmapRenderer。

Renderer。

RendererWithVisualVariables。

SimpleRenderer SimpleRenderer

SimpleRenderer。

UniqueValueRenderer UniqueValueRenderer

UniqueValueRenderer。

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.