### Install L7Plot with npm Source: https://github.com/antvis/l7plot/blob/main/README.en-US.md Install the L7Plot library and its peer dependency L7 using npm. ```bash $ npm install @antv/l7 @antv/l7plot ``` -------------------------------- ### HeatmapLayerStyleOptions configuration example Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/base-layers/heatmap-layer/style.zh.md Example of configuring the style for a regular heatmap layer, setting intensity, radius, opacity, and rampColors with colors and positions arrays. ```javascript { style: { intensity: 3, radius: 20, opacity: 1, rampColors: { colors: ['#FF4818', '#F7B74A', '#FFF598', '#F27DEB', '#8C1EB2', '#421EB2'], positions: [0, 0.2, 0.4, 0.6, 0.8, 1.0], }, } } ``` -------------------------------- ### GridHeatmapLayerStyleOptions configuration example Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/base-layers/heatmap-layer/style.zh.md Example of configuring the style for a grid or hexagon heatmap layer, setting coverage, angle, and opacity. ```javascript { style: { coverage: 0.9, angle: 0, opacity: 1.0, } } ``` -------------------------------- ### Install L7Plot with npm Source: https://github.com/antvis/l7plot/blob/main/packages/l7plot/README.md Installs the required packages @antv/l7 and @antv/l7plot via npm. ```bash npm install @antv/l7 @antv/l7plot ``` -------------------------------- ### Local development commands for L7Plot Source: https://github.com/antvis/l7plot/blob/main/packages/l7plot/README.md Commands for setting up the development environment, compiling packages, running the website, and executing tests, including installing yarn globally. ```bash npm install yarn -g ``` ```bash yarn bootstrap ``` ```bash yarn dev ``` ```bash yarn dev-website ``` ```bash yarn test ``` ```bash yarn test-live ``` -------------------------------- ### Local development commands Source: https://github.com/antvis/l7plot/blob/main/README.md Commands for local development: install yarn globally, bootstrap dependencies, run dev server, website, tests, and live test mode. ```bash # 全局安装 yarn $ npm install yarn -g # 安装项目依赖 $ yarn bootstrap # 实时编译各 package 并启动 storybook $ yarn dev # 运行网站 $ yarn dev-website # 运行单元测试 $ yarn test # 打开 electron 运行单元测试,并监听测试文件 $ yarn test-live ``` -------------------------------- ### getSource Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/base-layers/base-common/method.zh.md Gets the layer source instance. ```APIDOC ## getSource ### Description Gets the layer source instance. ### Method getSource ### Signature `layer.getSource(): ISource;` ### Returns - **ISource** - The source instance. ``` -------------------------------- ### Configure size as height for 3D grid/hexagon heatmap Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/base-layers/heatmap-layer/size.zh.md Example configuration for the `size` option when shape is a 3D grid or hexagon heatmap. Here `size` represents height and uses a function to multiply the value by 2. ```javascript { size: { field: 'value', value: ({ value }) => value * 2 } } ``` -------------------------------- ### Set ImageLayer style opacity Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/base-layers/image-layer/style.zh.md Example of configuring the `style` option for an ImageLayer, setting `opacity` to 1. The default value for `opacity` is 1, and it is optional. ```javascript { style: { opacity: 1, } } ``` -------------------------------- ### getScene: Get map scene instance Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/advanced-plot/index.zh.md Returns the map scene instance. ```javascript plot.getScene() : Scene; ``` -------------------------------- ### Configure image raster tile source Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/base-layers/raster-layer/source.zh.md Sets the source data to a tile URL template and uses the 'rasterTile' parser. This is the basic setup for displaying image-based raster tiles. ```javascript { source: { data: 'http://webst0{1-4}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}', parser: { type: 'rasterTile', }, }, } ``` -------------------------------- ### Example commit message with breaking change Source: https://github.com/antvis/l7plot/blob/main/CONTRIBUTING.md Example commit message showing the required format: a type and scope in the subject, a body explaining the change, and a footer with related issues and a BREAKING CHANGE note. Use this as a reference when writing commit messages for L7Plot. ```text fix($compile): [BREAKING_CHANGE] couple of unit tests for IE9 Older IEs serialize html uppercased, but IE9 does not... Would be better to expect case insensitive, unfortunately jasmine does not allow to user regexps for throw expectations. Document change on antvis/l7plot#123 Closes #392 BREAKING CHANGE: Breaks foo.bar api, foo.baz should be used instead ``` -------------------------------- ### Configure regular raster layer with TIFF data Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/base-layers/raster-layer/source.zh.md Fetches a TIFF file, reads its raster values, and constructs a source object with the 'raster' parser. The example includes the async function `getTiffData` and the resulting `source` object, which uses the fetched data and specifies width, height, min, max, and extent. ```javascript async function getTiffData() { const response = await fetch('https://gw.alipayobjects.com/os/rmsportal/XKgkjjGaAzRyKupCBiYW.dat'); const arrayBuffer = await response.arrayBuffer(); const tiff = await GeoTIFF.fromArrayBuffer(arrayBuffer); const image = await tiff.getImage(); const width = image.getWidth(); const height = image.getHeight(); const values = await image.readRasters(); return { data: values[0], width, height, min: 0, max: 8000, }; } const source = { data: tiffdata.data, parser: { type: 'raster', width: tiffData.width, height: tiffData.height, min: 0, max: 80, extent: [73.482190241, 3.82501784112, 135.106618732, 57.6300459963], }, }; ``` -------------------------------- ### Local development commands for L7Plot Source: https://github.com/antvis/l7plot/blob/main/README.en-US.md Commands for local development of the L7Plot project: install yarn globally, bootstrap dependencies, run the dev server, run the website, run unit tests, and open Electron for tests. ```bash # Global installation yarn $ npm install yarn -g # Install project dependencies $ yarn bootstrap # Compile each package in real time and start the storybook $ yarn dev # Run website $ yarn dev-website # Run unit tests $ yarn test # open electron for unit tests $ yarn test-live ``` -------------------------------- ### Configure size for heatmap with field and value Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/base-layers/heatmap-layer/size.zh.md Example configuration for the `size` option when shape is a regular heatmap (heatmap, heatmap3D). It maps the field 't' to a value range [0, 1]. ```javascript { source: { data: [{ lng: 104.101, lat: 30.649, t: 24.6, n: 'chengdu' }], parser: { type: 'json', x: 'lng', y: 'lat' } }, size: { field: 't', value: [0, 1], }, } ``` -------------------------------- ### getSource: Get layer source instance Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/base-layers/base-common/method.zh.md Returns the ISource instance associated with the layer. ```javascript layer.getSource(): ISource; ``` -------------------------------- ### AreaLayerStyle configuration example Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/layers/area-layer/style.zh.md Configures the area layer style with a fill opacity of 0.8, a white stroke, and a stroke width of 2. The lineDash property is optional and defaults to no dash; setting it to [0,0] disables the dash effect. ```js { style: { opacity: 0.8, stroke: 'white', lineWidth: 2, } } ``` -------------------------------- ### new Hexbin(container, options) Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/plots/hexbin.zh.md 创建蜂窝聚合图实例。container 为地图渲染的 DOM 容器,options 为蜂窝地图的所有配置项。 ```APIDOC ## new Hexbin(container, options) ### Description 创建蜂窝聚合图实例。 ### Constructor `new Hexbin(container, options)` ### Parameters - **container** (`string|HTMLDivElement`) - Required - 地图渲染的 DOM 容器。 - **options** (`HexbinOptions`) - Required - 蜂窝地图的所有配置项,继承自 [Plot options](/zh/docs/api/plot-api#options)。 ### Example ```ts import { Hexbin } from '@antv/l7plot'; const hexbin = new Hexbin(container, options); ``` ``` -------------------------------- ### new PointLayer(options: PointLayerOptions) Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/base-layers/point-layer.zh.md 创建点图层实例,需要传入 PointLayerOptions 配置对象。 ```APIDOC ## new PointLayer(options: PointLayerOptions) ### Description 创建点图层实例,需要传入 PointLayerOptions 配置对象。 ### Method constructor ### Endpoint new PointLayer(options: PointLayerOptions) ### Parameters #### options (PointLayerOptions) - Required - **type**: PointLayerOptions - **description**: 点图层的配置项,包含数据、样式、交互等。 ### Response 返回 PointLayer 实例。 ``` -------------------------------- ### getLegend Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/base-layers/base-common/method.zh.md Gets a legend by name. ```APIDOC ## getLegend ### Description Gets a legend by name. ### Method getLegend ### Signature `layer.getLegend(name: string): ILegend;` ### Parameters - **name** (string) - Required - The name of the legend. ### Returns - **ILegend** - The legend object. ``` -------------------------------- ### getLegendItems Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/base-layers/base-common/method.zh.md Gets legend data items. ```APIDOC ## getLegendItems ### Description Gets legend data items. ### Method getLegendItems ### Signature `layer.getLegendItems(type: string): Record[];` ### Parameters - **type** (string) - Required - The type of legend items. ### Returns - **Record[]** - An array of legend data items. ``` -------------------------------- ### new LineLayer(options: LineLayerOptions) Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/base-layers/line-layer.zh.md 创建线图层实例。LineLayer 是基于 L7-LineLayer 封装的配置式 API,通过传入配置项来初始化图层。 ```APIDOC ## new LineLayer(options: LineLayerOptions) ### Description 创建线图层实例。LineLayer 是基于 L7-LineLayer 封装的配置式 API,通过传入配置项来初始化图层。 ### Method Constructor ### Endpoint `new LineLayer(options: LineLayerOptions)` ### Parameters #### Constructor Parameters - **options** (LineLayerOptions) - Required - 线图层的配置项,包含数据源、形状、颜色、大小、样式、状态、动画等配置。 ### Request Example ```ts new LineLayer(options: LineLayerOptions) ``` ### Response #### Success Response 返回 LineLayer 实例。 ### Notes - 配置项详细说明请参考文档中的“配置”部分。 - 属性、方法和事件请参考文档中的相应部分。 ``` -------------------------------- ### getLegend Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/composite-layers/composite-common/method.zh.md Gets the legend for a given name. ```APIDOC ## getLegend ### Description Gets the legend for a given name. ### Method getLegend ### Signature `layer.getLegend(name: string): ILegend;` ### Parameters - **name** (string) - Required - The name of the legend. ### Returns - **ILegend** - The legend object. ``` -------------------------------- ### new Flow(container, options) Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/plots/flow.zh.md 创建流向图实例。container 为 DOM 容器,options 为 FlowOptions 配置对象,包含数据源、图层样式等。 ```APIDOC ## new Flow(container, options) ### Description 创建流向图实例。 ### Constructor `new Flow(container, options)` ### Parameters - **container** (`string|HTMLDivElement`) - Required - 地图渲染的 DOM 容器。 - **options** (`FlowOptions`) - Required - 连接图的所有配置项,继承自 [Plot options](/zh/docs/api/plot-api#options)。 ### Options #### `options.source` `SourceOptions` required - 数据配置,详见 [Source](/zh/docs/api/source)。 示例: ```js { source: { data: [{ startX: 58.00, startY: 32.84, endX: 85.7, endY: 25.161, c: 'red', t: 20, n: 'chengdu' }], parser: { type: 'json', x: 'startX', y: 'startY', x: 'endX', y: 'endY', } } } ``` #### 其他配置 - `shape` - 弧线形状配置(详见 shape 文档) - `color` - 颜色属性配置(详见 color 文档) - `size` - 大小属性配置(详见 size 文档) - `style` - 样式配置(详见 style 文档) - `radiation` - 辐射属性配置(详见 radiation 文档) - `animate` - 动画配置(详见 animate 文档) - `components` - 组件配置(详见 components 文档) ### 属性 - **flowLayer** (`ArcLayer`) - 弧线图层实例。 - **labelLayer** (`undefined|TextLayer`) - 数据标签图层实例。 ### 方法 继承 [Plot 方法](/zh/docs/api/plot-api#三、方法)。 ### 事件 继承 [Plot 方法](/zh/docs/api/plot-api#四、事件)。 内置图层名称: - `flowLayer` - `labelLayer` 事件示例: ```js pathMap.on('flowLayer:mousemove', (e: MouseEvent) => void); ``` ``` -------------------------------- ### getPlots: Get all plots Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/advanced-plot/index.zh.md Returns all plots in the container. ```javascript plot.getPlots(): Plot[]; ``` -------------------------------- ### Instantiate PointLayer with options Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/base-layers/point-layer.zh.md Creates a PointLayer instance with configuration options. This is the core API for the PointLayer, a configuration-based wrapper around L7-PointLayer. ```ts new PointLayer(options: PointLayerOptions) ``` -------------------------------- ### getLayers: Get all layers Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/advanced-plot/index.zh.md Returns all layers in the plot. ```javascript plot.getLayers(): PlotLayer[]; ``` -------------------------------- ### show: Show layer Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/base-layers/base-common/method.zh.md Makes the layer visible. ```javascript layer.show(); ``` -------------------------------- ### getLegend: Get legend Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/base-layers/base-common/method.zh.md Retrieves the legend with the given name. ```javascript layer.getLegend(name: string): ILegend; ``` -------------------------------- ### Configure source with data and geojson parser Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/base-layers/polygon-layer/source.zh.md Shows how to set the source option with the data object and a parser of type 'geojson'. ```javascript { source: { data, parser: { type: 'geojson' } } } ``` -------------------------------- ### getLegendItems Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/composite-layers/composite-common/method.zh.md Gets the legend data items for a given type. ```APIDOC ## getLegendItems ### Description Gets the legend data items for a given type. ### Method getLegendItems ### Signature `layer.getLegendItems(type: string): Record[];` ### Parameters - **type** (string) - Required - The type of legend items. ### Returns - **Record[]** - An array of legend data items. ``` -------------------------------- ### new Dot(container, options) Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/plots/dot.zh.md 创建 Dot 散点图实例。container 指定 DOM 容器,options 配置点地图的所有选项,包括数据源、形状、颜色、大小、样式、状态、动画及组件等属性。 ```APIDOC ## new Dot(container, options) ### Description 创建散点图实例,继承自 Plot 基类。 ### Constructor `new Dot(container: string | HTMLDivElement, options: DotOptions)` ### Parameters - **container** (`string | HTMLDivElement`) - 必填 - 地图渲染的 DOM 容器。 - **options** (`DotOptions`) - 必填 - 点地图的所有配置项,继承自 [Plot options](/zh/docs/api/plot-api#options)。 ### Options - **source** - 数据源配置。 - **shape** - 点形状配置。 - **color** - 颜色配置。 - **size** - 大小配置。 - **style** - 样式配置。 - **state** - 状态配置。 - **animate** - 动画配置。 - **components** - 组件配置。 ### Example ```ts import { Dot } from '@antv/l7plot'; const dotMap = new Dot(container, options); ``` ### Response 无返回值,创建实例后可通过实例访问属性和方法。 ``` -------------------------------- ### new GridMap(container, options) Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/plots/grid.zh.md 创建网格聚合图实例。container 为 DOM 容器,options 为配置项。 ```APIDOC ## new GridMap(container, options) ### Description 创建网格聚合图实例。 ### Parameters - **container** (string|HTMLDivElement) - Required - 地图渲染的 DOM 容器。 - **options** (GridMapOptions) - Required - 网格地图的所有配置项,继承自 Plot options。 ### Request Example ```ts import { GridMap } from '@antv/l7plot'; const gridMap = new GridMap(container, options); ``` ``` -------------------------------- ### getLegendItems: Get legend data Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/base-layers/base-common/method.zh.md Retrieves legend data for the given type. ```javascript layer.getLegendItems(type: string): Record[]; ``` -------------------------------- ### getCurrentDrillSteps Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/plots/choropleth.zh.md Gets the current drill step data. Use with drill functionality enabled. ```APIDOC ## getCurrentDrillSteps ### Description Gets the current drill step data. Use with drill functionality enabled. ### Method `getCurrentDrillSteps` ### Signature ```js plot.getCurrentDrillSteps(): ViewLevel[]; ``` ### Parameters None ### Returns - **ViewLevel[]** - Array of current drill step view levels. ``` -------------------------------- ### new HeatmapLayer(options: HeatmapLayerOptions) Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/base-layers/heatmap-layer.zh.md 创建热力图层实例。构造函数接受 HeatmapLayerOptions 配置对象。 ```APIDOC ## new HeatmapLayer(options: HeatmapLayerOptions) ### Description 创建热力图层实例。该构造函数接受一个配置对象,用于定义图层的样式、数据源、交互等。 ### Method Constructor ### Parameters #### options (HeatmapLayerOptions) - Required 配置对象,包含以下子配置项: - **配置** (object) - 图层配置,包括通用配置、数据源、形状、颜色、大小、样式等。 - **属性** (object) - 图层属性。 - **方法** (function) - 图层方法。 - **事件** (object) - 图层事件。 ### Request Example ```ts new HeatmapLayer(options: HeatmapLayerOptions) ``` ### Response 返回 HeatmapLayer 实例。 ``` -------------------------------- ### dotMap.on('dotLayer:click', handler) Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/plots/dot.zh.md 监听点图层点击事件。内置图层名称为 dotLayer 和 labelLayer,可通过 '图层名:事件名' 格式绑定事件。 ```APIDOC ## dotMap.on('dotLayer:click', handler) ### Description 监听点图层点击事件,内置图层名称包括 dotLayer 和 labelLayer。事件格式为 `图层名:事件名`。 ### Event Names - `dotLayer:click` - 点图层点击事件 - 其他事件继承自 [Plot 方法](/zh/docs/api/plot-api#四、事件) ### Example ```js dotMap.on('dotLayer:click', (e: MouseEvent) => void); ``` ### Parameters - **e** (`MouseEvent`) - 鼠标事件对象。 ``` -------------------------------- ### getInteractionSubLayers Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/composite-layers/composite-common/method.zh.md Gets the sub-layers that have interaction enabled, typically used for tooltip and event binding. ```APIDOC ## getInteractionSubLayers ### Description Gets the sub-layers that have interaction enabled, typically used for tooltip and event binding. ### Method getInteractionSubLayers ### Signature `layer.getInteractionSubLayers(): ICoreLayer[];` ### Returns - **ICoreLayer[]** - An array of core layers with interaction enabled. ``` -------------------------------- ### options.source Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/plots/choropleth.zh.md Configuration for the business data source and its join with geographic metadata. ```APIDOC ## options.source ### Description Configuration for the business data source and its join with geographic metadata. ### Parameters #### source - **data** (Array) - Required - The business data. - **joinBy** (JoinBy) - Required - The geographic metadata join configuration. #### joinBy - **sourceField** (string) - Required - The business metadata geographic field. - **geoField** ('adcode'|'name') - Optional - The geographic data field, default is 'adcode'. - **geoData** (FeatureCollection) - Optional - The geographic data, if set, overrides the current level's administrative address data. ### Examples 1. Match by administrative code: ```js { source: { data: [{ cityName: '上海市', code: 310000, value: 200 }], joinBy: { sourceField: 'code', geoField: 'adcode', }, }, } ``` 2. Match by administrative name: ```js { source: { data: [{ cityName: '上海市', code: 310000, value: 200 }], joinBy: { sourceField: 'cityName', geoField: 'name', }, }, } ``` ``` -------------------------------- ### getPlotByName: Get plot by name Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/advanced-plot/index.zh.md Returns the plot with the given name, or undefined if not found. ```javascript plot.getPlotByName(name: string): Plot | undefined; ``` -------------------------------- ### getLayerByName: Get layer by name Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/advanced-plot/index.zh.md Returns the layer with the given name, or undefined if not found. ```javascript plot.getLayerByName(name: string): PlotLayer | undefined; ``` -------------------------------- ### new RasterLayer(options: RasterLayerOptions) Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/base-layers/raster-layer.zh.md 创建栅格图层实例。该构造函数接受一个配置对象,用于定义图层的行为和样式。 ```APIDOC ## new RasterLayer(options: RasterLayerOptions) ### Description 创建栅格图层实例。该构造函数接受一个配置对象,用于定义图层的行为和样式。 ### Constructor `new RasterLayer(options: RasterLayerOptions)` ### Parameters #### options (RasterLayerOptions) - Required 配置对象,包含以下可选字段: - **name** (string) - Optional - 图层名。 - **id** (string) - Optional - 图层 ID。 - **zIndex** (number) - Optional - 图层层叠顺序,数值越大,图层层叠最高。默认值:`0`。 - **visible** (boolean) - Optional - 图层是否可见。默认值:`true`。 - **minZoom** (number) - Optional - 图层可见最小缩放层级。 - **maxZoom** (number) - Optional - 图层可见最大缩放层级。 - **autoFit** (boolean) - Optional - 图层加载成功后是否自动定位到图层数据可见范围。默认值:`false`。 - **blend** (string) - Optional - 图层的元素混合效果,支持 `normal`、`additive`、`subtractive`、`max`。默认值:`normal`。 ### Example ```ts new RasterLayer({ name: 'myRasterLayer', zIndex: 1, visible: true, autoFit: false, blend: 'normal' }) ``` ``` -------------------------------- ### getMap: Get map instance Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/advanced-plot/index.zh.md Returns the map instance, either Mapbox or AMap. ```javascript plot.getMap() : MapboxInstance | AMapInstance; ``` -------------------------------- ### Path Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/plots/path.zh.md Constructor for creating a Path map instance. ```APIDOC ## Path ### Description Creates a new Path map instance. ### Constructor `new Path(container, options)` ### Parameters - **container** (`string|HTMLDivElement`) - Required - The DOM container for the map. - **options** (`PathOptions`) - Required - Configuration options for the path map, inheriting from Plot options. ### Example ```ts import { Path } from '@antv/l7plot'; const path = new Path(container, options); ``` ``` -------------------------------- ### new ImageLayer(options: ImageLayerOptions) Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/base-layers/image-layer.zh.md 创建图片图层实例。该构造函数接受一个配置对象,用于定义图层的名称、ID、层级、可见性、缩放范围、自动适配和混合模式等属性。 ```APIDOC ## new ImageLayer(options: ImageLayerOptions) ### Description 创建图片图层实例。该构造函数接受一个配置对象,用于定义图层的名称、ID、层级、可见性、缩放范围、自动适配和混合模式等属性。 ### Method Constructor ### Endpoint `new ImageLayer(options: ImageLayerOptions)` ### Parameters #### Options - **name** (`string`) - Optional - 图层名。 - **id** (`string`) - Optional - 图层 ID。 - **zIndex** (`number`) - Optional, default: `0` - 图层层叠顺序,数值越大,图层层叠最高。 - **visible** (`boolean`) - Optional, default: `true` - 图层是否可见。 - **minZoom** (`number`) - Optional - 图层可见最小缩放层级。 - **maxZoom** (`number`) - Optional - 图层可见最大缩放层级。 - **autoFit** (`boolean`) - Optional, default: `false` - 图层加载成功后是否自动定位到图层数据可见范围,注意开启后图层数据发生更新时,地图也会自动缩放到图层的数据边界范围。 - **blend** (`string`) - Optional, default: `normal` - 图层的元素混合效果,支持以下效果:`normal`(正常效果,默认效果)、`additive`(叠加模式)、`subtractive`(相减模式)、`max`(最大值)。 ### Response 返回一个 ImageLayer 实例。 ``` -------------------------------- ### options.getClusterLocationName Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/composite-layers/flow-layer.zh.md Method to get the name of a cluster location. It can return a string or a Promise that resolves to a string. ```APIDOC ## options.getClusterLocationName ### Description Method to get the name of a cluster location. It can return a string or a Promise that resolves to a string. ### Signature `(clusterLocation: ClusterLocation, index: number) => Promise | string` ### Parameters - **clusterLocation** (ClusterLocation) - Required - The cluster location object. - **index** (number) - Required - The index of the cluster location. ### Returns - **Promise | string** - The name of the cluster location. ### Default `undefined` ``` -------------------------------- ### hexbin.on(event, callback) Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/plots/hexbin.zh.md 监听蜂窝聚合图事件,事件名称格式为 '图层名:事件名'。内置图层名称包括 hexbinLayer 和 labelLayer。 ```APIDOC ## hexbin.on(event, callback) ### Description 监听蜂窝聚合图事件。事件名称格式为 '图层名:事件名',内置图层名称包括 hexbinLayer 和 labelLayer。 ### Method `on` ### Parameters - **event** (`string`) - Required - 事件名称,格式为 '图层名:事件名',例如 'hexbinLayer:click'。 - **callback** (`Function`) - Required - 事件回调函数,接收事件对象。 ### Example ```js hexbin.on('hexbinLayer:click', (e: MouseEvent) => void); ``` ``` -------------------------------- ### Get plot map instance Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/plot-api/index.zh.md Returns the map instance of the plot, which can be a Map, Mapbox, or AMap instance. ```javascript plot.getMap() : MapInstance | MapboxInstance | AMapInstance; ``` -------------------------------- ### getInteractionSubLayers: Get interaction sub-layers Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/composite-layers/composite-common/method.zh.md Retrieves sub-layers with interaction, typically used for enabling tooltips and binding layer events. ```js layer.getInteractionSubLayers(): ICoreLayer[]; ``` -------------------------------- ### show Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/base-layers/base-common/method.zh.md Shows the layer. ```APIDOC ## show ### Description Shows the layer. ### Method show ### Signature `layer.show();` ``` -------------------------------- ### Import Dot from @antv/l7plot Source: https://github.com/antvis/l7plot/blob/main/website/docs/manual/quick-start/index.zh.md Imports the Dot component from the L7Plot library after installation. This is the standard ES module import for using L7Plot in a JavaScript project. ```js import { Dot } from '@antv/l7plot'; ``` -------------------------------- ### Create Heatmap instance Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/plots/heatmap.zh.md Imports the Heatmap class from @antv/l7plot and creates a new instance with a container and options. ```ts import { Heatmap } from '@antv/l7plot'; const heatmap = new Heatmap(container, options); ``` -------------------------------- ### 创建 TextLayer 实例 Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/base-layers/text-layer.zh.md 使用 new TextLayer(options) 创建文本图层实例,options 为 TextLayerOptions 类型。 ```ts new TextLayer(options: TextLayerOptions) ``` -------------------------------- ### Create a Path instance with @antv/l7plot Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/plots/path.zh.md Creates a Path map instance with the required container and options. The container is a DOM element or selector, and options configure the path layer and its components. ```ts import { Path } from '@antv/l7plot'; const path = new Path(container, options); ``` -------------------------------- ### Map size to a data field Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/layers/arc-layer/size.zh.md Maps the size to the 't' field of the data. The parser uses 'startX' and 'startY' for the start point and 'endX' and 'endY' for the end point. ```js { source: { data: [{ startX: 58.00, startY: 32.84, endX: 85.7, endY: 25.161, c: 'red', t: 20, n: 'chengdu' }], parser: { type: 'json', x: 'startX', y: 'startY', x: 'endX', y: 'endY', } }, size: { field: 't', } } ``` -------------------------------- ### Access L7 scene methods like getZoom Source: https://github.com/antvis/l7plot/blob/main/website/docs/manual/faq/index.zh.md Get the L7 scene instance from the plot using plot.scene or plot.getScene(), then call methods like getZoom after the 'loaded' event. ```js // 通过实例 const scene = plot.scene; // 或 const scene = plot.getScene(); plot.on('loaded', () => { scene.getZoom(); // ... }); ``` -------------------------------- ### gridMap.on('gridLayer:click', callback) Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/plots/grid.zh.md 监听网格图层点击事件。事件名称格式为 '图层名:事件名'。 ```APIDOC ## gridMap.on('gridLayer:click', callback) ### Description 监听网格图层点击事件。 ### Parameters - **eventName** (string) - Required - 事件名称,格式为 '图层名:事件名',例如 'gridLayer:click'。 - **callback** (Function) - Required - 事件回调函数,接收 MouseEvent 参数。 ### Request Example ```js gridMap.on('gridLayer:click', (e: MouseEvent) => void); ``` ``` -------------------------------- ### 创建 PolygonLayer 实例 Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/base-layers/polygon-layer.zh.md 使用 new PolygonLayer(options) 创建面图层实例,options 为 PolygonLayerOptions 配置对象。 ```ts new PolygonLayer(options: PolygonLayerOptions) ``` -------------------------------- ### Define GeoJSON data for polygon layer source Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/base-layers/polygon-layer/source.zh.md Example of a GeoJSON FeatureCollection with a Polygon feature, used as the data for the source option. The properties include name, code, c, and t. ```javascript const data = { type: 'FeatureCollection', features: [ { type: 'Feature', properties: { name: '上海市', code: 310000, c: 'red', t: 20 }, geometry: { type: 'Polygon', coordinates: [ [ [115.1806640625, 30.637912028341123], [114.9609375, 29.152161283318915], [117.79541015625001, 27.430289738862594], [118.740234375, 29.420460341013133], [117.46582031249999, 31.50362930577303], [115.1806640625, 30.637912028341123], // ...... ], ], }, }, ], }; ``` -------------------------------- ### Create GridMap instance Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/plots/grid.zh.md Creates a GridMap instance with a DOM container and GridMapOptions. The container can be a string selector or an HTMLDivElement. ```ts import { GridMap } from '@antv/l7plot'; const gridMap = new GridMap(container, options); ``` -------------------------------- ### Category legend customContent example Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/components/legend.zh.md Custom legend content function for category legends. It receives the title and legend items, and must return an HTMLElement or an HTML string (not plain text). ```js customContent (title: string, items: ILegendListItem[]) { const container = document.createElement('div'); container.innerHTML = '内容' return container; } ``` -------------------------------- ### 创建 ImageLayer 实例 Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/base-layers/image-layer.zh.md 使用 new ImageLayer(options) 创建图片图层实例,options 为 ImageLayerOptions 类型。 ```ts new ImageLayer(options: ImageLayerOptions) ``` -------------------------------- ### getScene Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/plot-api/index.zh.md 获取图表的地图 scene 实例。 ```APIDOC ## getScene ### Description 获取图表的地图 scene 实例。 ### Method getScene ### Signature ```js plot.getScene() : Scene; ``` ### Returns - **Scene** - 地图 scene 实例。 ``` -------------------------------- ### addToScene Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/plot-api/index.zh.md 添加到容器,用于 L7 Scene 与图表混合使用场景。 ```APIDOC ## addToScene ### Description 添加到容器,用于 L7 Scene 与图表混合使用场景。 ### Method addToScene ### Signature ```js plot.addToScene(scene: Scene); ``` ### Parameters - **scene** (Scene) - 必填 - L7 Scene 实例。 ``` -------------------------------- ### new Choropleth(container, options) Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/plots/choropleth.zh.md Creates a new Choropleth map instance. The constructor takes a DOM container and configuration options. ```APIDOC ## new Choropleth(container, options) ### Description Creates a new Choropleth map instance for rendering administrative area distribution maps. ### Constructor `new Choropleth(container, options)` ### Parameters #### container - **container** (string|HTMLDivElement) - Required - The DOM container for map rendering. #### options - **options** (ChoroplethOptions) - Required - All configuration options for the choropleth map, inheriting from Plot options. ### Example ```ts import { Choropleth } from '@antv/l7plot'; const choropleth = new Choropleth(container, options); ``` ``` -------------------------------- ### Configure viewLevel with level, adcode, and granularity Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/plots/choropleth.zh.md Sets the administrative level and scope. The granularity defaults to the next level below the specified level. ```js { viewLevel: { level: 'country', adcode: '100000', granularity: 'province', } } ``` -------------------------------- ### PolygonLayer Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/base-layers/polygon-layer.zh.md Documentation for the PolygonLayer class, including its constructor, configuration options, properties, methods, and events. ```APIDOC ## PolygonLayer ### Description `PolygonLayer` is a configuration-style API based on [L7-PolygonLayer](https://l7.antv.vision/zh/docs/api/polygon_layer/polygonlayer). It is used to create a polygon layer in L7Plot. ### Constructor ```ts new PolygonLayer(options: PolygonLayerOptions) ``` ### Parameters - **options** (PolygonLayerOptions) - Required - Configuration options for the polygon layer. ### Configuration Options - **source** - Data source configuration for the polygon layer. - **shape** - Shape configuration for the polygon layer. - **color** - Color attribute configuration. - **size** - Size attribute configuration. - **style** - Style configuration for the polygon layer. - **state** - State attribute configuration. ### Properties - **attribute** - Common attributes for base layers. ### Methods - **method** - Common methods for base layers. ### Events - **event** - Common events for base layers. ``` -------------------------------- ### getLayers Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/plot-api/index.zh.md 获取所有图层。 ```APIDOC ## getLayers ### Description 获取所有图层。 ### Method getLayers ### Signature ```js plot.getLayers(): PlotLayer[]; ``` ### Returns - **PlotLayer[]** - 图层数组。 ``` -------------------------------- ### Create a Dot map instance Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/plots/dot.zh.md Imports the Dot class from '@antv/l7plot' and creates a new instance with a container and options object. ```TypeScript import { Dot } from '@antv/l7plot'; const dotMap = new Dot(container, options); ``` -------------------------------- ### Configure state with active and select options Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/layers/area-layer/state.zh.md Shows the full `state` configuration object with an `active` highlight style and `select` disabled. The `active` object sets stroke color, line width, and line opacity for hover effects. ```javascript { state: { active: { stroke: 'yellow', lineWidth: 1.5, lineOpacity: 0.8, }, select: false, } } ``` -------------------------------- ### IconLayer 配置 Source: https://github.com/antvis/l7plot/blob/main/website/docs/api/layers/icon-layer.zh.md IconLayer 的配置项,包括 source、shape、color、size、style 和 state。其中 shape 为必填项,需先注册图标。 ```APIDOC ## IconLayer 配置 ### Description IconLayer 继承自 PlotLayer,用于在地图上展示图标点图层。配置项包括数据源、图标形状、颜色、大小、样式和状态。 ### 配置项 #### `options.source` - **类型**: 数据源配置 - **必填**: 是 - **描述**: 数据源配置,支持 JSON、CSV 等格式,需指定 x、y 字段。 #### `options.shape` - **类型**: `string` | `object` - **必填**: 是 - **描述**: 图标形状。可以是已注册的图标 ID,或通过字段映射和回调函数自定义。 ##### 注册图标 ```js const images = [ { id: '01', image: 'https://gw.alipayobjects.com/zos/basement_prod/604b5e7f-309e-40db-b95b-4fac746c5153.svg' }, { id: '02', image: 'https://gw.alipayobjects.com/zos/basement_prod/30580bc9-506f-4438-8c1a-744e082054ec.svg' }, { id: '03', image: 'https://gw.alipayobjects.com/zos/basement_prod/7aa1f460-9f9f-499f-afdf-13424aa26bbf.svg' }, ]; registerImages(images); ``` ##### 使用注册图标 ```js { source: { data: [{ lng: 104.101, lat: 30.649, s: '01', t: 21, n: 'chengdu' }], parser: { type: 'json', x: 'lng', y: 'lat' } }, shape: '01', } ``` ##### 自定义映射图标 ```js { shape: { field: 't', value: ({ t }) => { return t > 20 ? '01': '02' } } } ``` #### `options.color` - **类型**: 颜色配置 - **必填**: 否 - **描述**: 颜色配置,支持字段映射和回调。 #### `options.size` - **类型**: 大小配置 - **必填**: 否 - **描述**: 大小配置,支持字段映射和回调。 #### `options.style` - **类型**: 样式配置 - **必填**: 否 - **描述**: 样式配置,如透明度、旋转等。 #### `options.state` - **类型**: 状态配置 - **必填**: 否 - **描述**: 交互状态配置,如选中、悬停等。 ### 属性、方法和事件 继承自 [PlotLayer](/zh/docs/api/layers/plot-layer)。 ``` -------------------------------- ### Configure state with active and select options Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/composite-layers/choropleth-layer/state.zh.md Shows the full `state` configuration object with `active` and `select` properties. `active` is a ChoroplethLayerActiveOptions object with `fillColor`, `strokeColor`, and `lineWidth`; `select` is set to `false` to disable selection. ```javascript { state: { active: { fillColor: false, strokeColor: '#2f54eb', lineWidth: 1, }, select: false, } } ``` -------------------------------- ### Configure data raster tile with custom format Source: https://github.com/antvis/l7plot/blob/main/website/docs/common/base-layers/raster-layer/source.zh.md Sets up a raster tile source with a custom `format` function that processes arraybuffer data into raster data. The function converts the tile to an image, draws it on a canvas, extracts the red channel, and returns an object with `rasterData`, `width`, and `height`. ```javascript { source: { data: 'http://webst0{1-4}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}', parser: { type: 'rasterTile', dataType: 'arraybuffer', tileSize: 256, extent: [-180, -85.051129, 179, 85.051129], format: async (data: any) => { const blob: Blob = new Blob([new Uint8Array(data)], { type: 'image/png', }); const img = await createImageBitmap(blob); ctx.clearRect(0, 0, 256, 256); ctx.drawImage(img, 0, 0, 256, 256); const imgData = ctx.getImageData(0, 0, 256, 256).data; const arr: number[] = []; for (let i = 0; i < imgData.length; i += 4) { const R = imgData[i]; arr.push(R); } return { rasterData: arr, width: 256, height: 256, }; }, }, }, } ```