From 24b62915f8a63f8636bef927867f37d5171882c3 Mon Sep 17 00:00:00 2001 From: lvisei Date: Fri, 11 Nov 2022 17:11:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9C=B0=E5=9B=BE=E5=BA=95=E5=9B=BE?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=AB=98=E5=BE=B7V2=20(#248)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../choropleth-layer/index.ts | 2 +- .../src/core/composite-layer.ts | 4 +- .../composite-layers/src/core/core-layer.ts | 4 +- .../composite-layers/src/types/interface.ts | 62 ++++++------------- .../unit/adaptor/layer/index.spec.ts | 2 +- .../unit/layers/column-layer/index.test.ts | 2 +- .../unit/layers/dot-layer/index.test.ts | 2 +- .../unit/layers/heatmap-layer/index.test.ts | 2 +- .../unit/layers/icon-layer/index.test.ts | 2 +- .../unit/layers/text-layer/index.test.ts | 2 +- packages/l7plot/src/component/legend.ts | 4 +- packages/l7plot/src/component/tooltip.ts | 15 +---- packages/l7plot/src/core/layer/plot-layer.ts | 2 +- packages/l7plot/src/core/map/index.ts | 23 ++++--- packages/l7plot/src/core/plot/index.ts | 4 +- .../l7plot/src/layers/area-layer/index.ts | 2 +- packages/l7plot/src/layers/dot-layer/index.ts | 2 +- .../l7plot/src/layers/grid-layer/index.ts | 2 +- .../src/layers/heatmap-layer/adaptor.ts | 2 +- .../l7plot/src/layers/heatmap-layer/index.ts | 2 +- .../l7plot/src/layers/hexbin-layer/index.ts | 2 +- .../l7plot/src/layers/lines-layer/index.ts | 2 +- .../l7plot/src/layers/prism-layer/index.ts | 2 +- .../l7plot/src/layers/text-layer/index.ts | 2 +- packages/l7plot/src/plots/choropleth/index.ts | 3 +- packages/l7plot/src/types/attr.ts | 2 +- packages/l7plot/src/types/common.ts | 11 ++-- packages/l7plot/src/types/control.ts | 4 +- packages/l7plot/src/types/layer.ts | 2 +- packages/l7plot/src/types/legend.ts | 2 +- packages/l7plot/src/types/map.ts | 23 +++---- packages/l7plot/src/types/popup.ts | 2 +- packages/l7plot/src/types/tooltip.ts | 2 +- website/docs/api/plot-api/index.zh.md | 2 +- website/docs/common/attribute/map.zh.md | 11 ++-- website/docs/manual/faq/index.zh.md | 4 +- 36 files changed, 100 insertions(+), 118 deletions(-) diff --git a/packages/composite-layers/src/composite-layers/choropleth-layer/index.ts b/packages/composite-layers/src/composite-layers/choropleth-layer/index.ts index ca41d07b2..e8cba559c 100644 --- a/packages/composite-layers/src/composite-layers/choropleth-layer/index.ts +++ b/packages/composite-layers/src/composite-layers/choropleth-layer/index.ts @@ -199,7 +199,7 @@ export class ChoroplethLayer extends CompositeLayer { }; const options = { - visible, + visible: visible && Boolean(lineWidth) && Boolean(strokeColor), zIndex, minZoom, maxZoom, diff --git a/packages/composite-layers/src/core/composite-layer.ts b/packages/composite-layers/src/core/composite-layer.ts index 413bfe2a2..f910efa6e 100644 --- a/packages/composite-layers/src/core/composite-layer.ts +++ b/packages/composite-layers/src/core/composite-layer.ts @@ -340,11 +340,11 @@ export abstract class CompositeLayer extends Ev /** * 事件代理: 绑定事件 */ - public on(name: string, callback: (...args: any[]) => void) { + public on(name: string, callback: (...args: any[]) => void, once?: boolean) { if (OriginLayerEventList.indexOf(name) !== -1) { this.layer.on(name, callback); } else { - super.on(name, callback); + super.on(name, callback, once); } return this; } diff --git a/packages/composite-layers/src/core/core-layer.ts b/packages/composite-layers/src/core/core-layer.ts index 41ca5df4d..0e7e253dd 100644 --- a/packages/composite-layers/src/core/core-layer.ts +++ b/packages/composite-layers/src/core/core-layer.ts @@ -401,11 +401,11 @@ export abstract class CoreLayer extends EventEmitter /** * 事件代理: 绑定事件 */ - public on(name: string, callback: (...args: any[]) => void) { + public on(name: string, callback: (...args: any[]) => void, once?: boolean) { if (OriginLayerEventList.indexOf(name) !== -1) { this.layer.on(name, callback); } else { - super.on(name, callback); + super.on(name, callback, once); } return this; } diff --git a/packages/composite-layers/src/types/interface.ts b/packages/composite-layers/src/types/interface.ts index 5a4537f66..e91ffbf85 100644 --- a/packages/composite-layers/src/types/interface.ts +++ b/packages/composite-layers/src/types/interface.ts @@ -26,17 +26,14 @@ export interface ILayerGroup { } /** - * 核心图层的基类接口 + * 图层的基础接口 */ -export interface ICoreLayer { +interface IBaseLayer { options: Record; name: string; id: string; type: string; - interaction: boolean; - layer: ILayer; - inited: boolean; - source: ISource; + isComposite: boolean; addTo(scene: Scene): void; remove(): void; @@ -45,8 +42,6 @@ export interface ICoreLayer { updateOption(options: unknown): void; changeData(data: SourceOptions): void; - setSource(source: ISource): void; - getSource(): ISource; render(): void; show(): void; @@ -59,59 +54,40 @@ export interface ICoreLayer { setMaxZoom(maxZoom: number): void; setBlend(blend: LayerBlend): void; - boxSelect(bounds: [number, number, number, number], callback: (...args: any[]) => void): void; - fitBounds(fitBoundsOptions?: unknown): void; getLegend(name: string): ILegend; getLegendItems(type: string): Record[]; destroy(): void; - on(name: string, callback: (...args: any[]) => void): this; + on(name: string, callback: (...args: any[]) => void, once?: boolean): this; once(name: string, callback: (...args: any[]) => void): this; off(name: string, callback: (...args: any[]) => void): this; } /** - * 复合图层的基类接口 + * 核心图层的基类接口 */ -export interface ICompositeLayer { - options: Record; - name: string; - id: string; - type: string; - - subLayers: ILayerGroup; - - addTo(scene: Scene): void; - remove(): void; +export interface ICoreLayer extends IBaseLayer { + interaction: boolean; - update(options: unknown): void; - updateOption(options: unknown): void; + layer: ILayer; + inited: boolean; + source: ISource; - changeData(data: SourceOptions): void; - render(): void; + setSource(source: ISource): void; + getSource(): ISource; - show(): void; - hide(): void; - toggleVisible(): void; - isVisible(): boolean; + boxSelect(bounds: [number, number, number, number], callback: (...args: any[]) => void): void; +} - setIndex(zIndex: number): void; - setMinZoom(minZoom: number): void; - setMaxZoom(maxZoom: number): void; - setBlend(blend: LayerBlend): void; +/** + * 复合图层的基类接口 + */ +export interface ICompositeLayer extends IBaseLayer { + subLayers: ILayerGroup; - fitBounds(fitBoundsOptions?: unknown): void; - getLegend(name: string): ILegend; - getLegendItems(type: string): Record[]; getColorLegendItems(): Record[]; getInteractionSubLayers(): ICoreLayer[]; - - destroy(): void; - - on(name: string, callback: (...args: any[]) => void): this; - once(name: string, callback: (...args: any[]) => void): this; - off(name: string, callback: (...args: any[]) => void): this; } diff --git a/packages/l7plot/__tests__/unit/adaptor/layer/index.spec.ts b/packages/l7plot/__tests__/unit/adaptor/layer/index.spec.ts index 8a2d2069a..3d96355f8 100644 --- a/packages/l7plot/__tests__/unit/adaptor/layer/index.spec.ts +++ b/packages/l7plot/__tests__/unit/adaptor/layer/index.spec.ts @@ -1,6 +1,6 @@ +import { Source } from '@antv/l7'; import { getLayerStyleAttribute } from '../../../helper/layer'; import { DotLayer } from '../../../../src/layers/dot-layer'; -import { Source } from '../../../../src/types'; import { DotLayerOptions } from '../../../../src/layers/dot-layer'; import { LinesLayer, LinesLayerOptions } from '../../../../src/layers/lines-layer'; diff --git a/packages/l7plot/__tests__/unit/layers/column-layer/index.test.ts b/packages/l7plot/__tests__/unit/layers/column-layer/index.test.ts index 3cf5af64d..ca6fdf229 100644 --- a/packages/l7plot/__tests__/unit/layers/column-layer/index.test.ts +++ b/packages/l7plot/__tests__/unit/layers/column-layer/index.test.ts @@ -1,6 +1,6 @@ +import { Source } from '@antv/l7'; import { getLayerStyleAttribute } from '../../../helper/layer'; import { ColumnLayer } from '../../../../src/layers/column-layer'; -import { Source } from '../../../../src/types'; describe('column layer', () => { const layer = new ColumnLayer({ diff --git a/packages/l7plot/__tests__/unit/layers/dot-layer/index.test.ts b/packages/l7plot/__tests__/unit/layers/dot-layer/index.test.ts index eb26ba3c7..5a050505f 100644 --- a/packages/l7plot/__tests__/unit/layers/dot-layer/index.test.ts +++ b/packages/l7plot/__tests__/unit/layers/dot-layer/index.test.ts @@ -1,6 +1,6 @@ +import { Source } from '@antv/l7'; import { getLayerStyleAttribute } from '../../../helper/layer'; import { DotLayer } from '../../../../src/layers/dot-layer'; -import { Source } from '../../../../src/types'; describe('dot layer', () => { const layer = new DotLayer({ diff --git a/packages/l7plot/__tests__/unit/layers/heatmap-layer/index.test.ts b/packages/l7plot/__tests__/unit/layers/heatmap-layer/index.test.ts index 454e9662a..c89ad2ea5 100644 --- a/packages/l7plot/__tests__/unit/layers/heatmap-layer/index.test.ts +++ b/packages/l7plot/__tests__/unit/layers/heatmap-layer/index.test.ts @@ -1,6 +1,6 @@ +import { Source } from '@antv/l7'; import { getLayerStyleAttribute } from '../../../helper/layer'; import { HeatmapLayer } from '../../../../src/layers/heatmap-layer'; -import { Source } from '../../../../src/types'; describe('heatmap layer', () => { const layer = new HeatmapLayer({ diff --git a/packages/l7plot/__tests__/unit/layers/icon-layer/index.test.ts b/packages/l7plot/__tests__/unit/layers/icon-layer/index.test.ts index a2e9067e8..18a8fa1d0 100644 --- a/packages/l7plot/__tests__/unit/layers/icon-layer/index.test.ts +++ b/packages/l7plot/__tests__/unit/layers/icon-layer/index.test.ts @@ -1,6 +1,6 @@ +import { Source } from '@antv/l7'; import { getLayerStyleAttribute } from '../../../helper/layer'; import { IconLayer } from '../../../../src/layers/icon-layer'; -import { Source } from '../../../../src/types'; import { registerImages } from '../../../../src'; describe('icon layer', () => { diff --git a/packages/l7plot/__tests__/unit/layers/text-layer/index.test.ts b/packages/l7plot/__tests__/unit/layers/text-layer/index.test.ts index 1c360fcd8..615c1f9d3 100644 --- a/packages/l7plot/__tests__/unit/layers/text-layer/index.test.ts +++ b/packages/l7plot/__tests__/unit/layers/text-layer/index.test.ts @@ -1,6 +1,6 @@ +import { Source } from '@antv/l7'; import { getLayerStyleAttribute } from '../../../helper/layer'; import { TextLayer } from '../../../../src/layers/text-layer'; -import { Source } from '../../../../src/types'; describe('text layer', () => { const layer = new TextLayer({ diff --git a/packages/l7plot/src/component/legend.ts b/packages/l7plot/src/component/legend.ts index 515fc9f9e..754265a5d 100644 --- a/packages/l7plot/src/component/legend.ts +++ b/packages/l7plot/src/component/legend.ts @@ -1,5 +1,5 @@ -import { IControlOption } from '@antv/l7'; -import { Control } from '@antv/l7-component'; +import type { IControlOption } from '@antv/l7'; +import { Control } from '@antv/l7'; import { CategoryLegendOptions, ContinueLegendOptions, CategoryLegend, ContinueLegend } from '@antv/l7plot-component'; export type LegendItem = diff --git a/packages/l7plot/src/component/tooltip.ts b/packages/l7plot/src/component/tooltip.ts index 34ff93e01..1a5fbfc1e 100644 --- a/packages/l7plot/src/component/tooltip.ts +++ b/packages/l7plot/src/component/tooltip.ts @@ -1,5 +1,4 @@ -import { Scene } from '@antv/l7-scene'; -import { Marker } from '@antv/l7-component'; +import { Scene, Marker } from '@antv/l7'; import EventEmitter from '@antv/event-emitter'; import { isString, isEqual } from '@antv/util'; import { @@ -8,16 +7,8 @@ import { TooltipListItem, } from '@antv/l7plot-component'; import { get as getValueByPath } from 'lodash-es'; -import { - IPlotLayer, - ILngLat, - TooltipAnchorType, - Event, - TooltipOptions, - MouseEvent, - TooltipItem, - TooltipEvent, -} from '../types'; +import type { IPlotLayer, ILngLat, Event, TooltipOptions, MouseEvent, TooltipItem, TooltipEvent } from '../types'; +import { TooltipAnchorType } from '../types'; import { deepAssign } from '../utils'; const TRIGGER_LIST = ['mousemove', 'click']; diff --git a/packages/l7plot/src/core/layer/plot-layer.ts b/packages/l7plot/src/core/layer/plot-layer.ts index 522579b0b..6b178d9b0 100644 --- a/packages/l7plot/src/core/layer/plot-layer.ts +++ b/packages/l7plot/src/core/layer/plot-layer.ts @@ -1,5 +1,5 @@ import { isEqual, isUndefined, pick } from '@antv/util'; -import Source from '@antv/l7-source'; +import { Source } from '@antv/l7'; import EventEmitter from '@antv/event-emitter'; import { LayerType, IPlotLayer, PlotLayerOptions, LayerBlend } from '../../types/layer'; import { Scene, ILayer, ILayerConfig, SourceOptions } from '../../types'; diff --git a/packages/l7plot/src/core/map/index.ts b/packages/l7plot/src/core/map/index.ts index f29aba979..b3d8d9bb7 100644 --- a/packages/l7plot/src/core/map/index.ts +++ b/packages/l7plot/src/core/map/index.ts @@ -1,14 +1,13 @@ -import { Scene } from '@antv/l7-scene'; -import { Mapbox, GaodeMap } from '@antv/l7-maps'; -import { Scale, Zoom } from '@antv/l7-component'; +import { Scene, Mapbox, GaodeMap, GaodeMapV2, Map as L7Map, Scale, Zoom } from '@antv/l7'; import EventEmitter from '@antv/event-emitter'; import { isObject, isBoolean, isUndefined, isEqual } from '@antv/util'; import { Tooltip } from '../../component/tooltip'; import { Legend, LegendItem } from '../../component/legend'; import { deepAssign } from '../../utils'; -import { - BaseMapType, +import { BaseMapType } from '../../types'; +import type { MapOptions, + MapInstance, AMapInstance, MapboxInstance, ZoomControlOptions, @@ -147,7 +146,13 @@ export abstract class Map extends EventEmitter { const { type, ...config } = mapConfig; const options = Object.assign({ style: this.theme['mapStyle'] }, config); - return type === BaseMapType.Amap ? new GaodeMap(options) : new Mapbox(options); + return type === BaseMapType.Amap + ? new GaodeMap(options) + : type === BaseMapType.AmapV2 + ? new GaodeMapV2(options) + : type === BaseMapType.Mapbox + ? new Mapbox(options) + : new L7Map(options); } /** @@ -322,11 +327,15 @@ export abstract class Map extends EventEmitter { /** * 获取 map 实例 */ - public getMap(): MapboxInstance | AMapInstance | unknown { + public getMap(): MapboxInstance | AMapInstance | MapInstance | unknown { if (this.options.map?.type === BaseMapType.Amap) { return this.scene.map as AMapInstance; + } else if (this.options.map?.type === BaseMapType.AmapV2) { + return this.scene.map as AMapInstance; } else if (this.options.map?.type === BaseMapType.Mapbox) { return this.scene.map as MapboxInstance; + } else if (this.options.map?.type === BaseMapType.Map) { + return this.scene.map as MapInstance; } else { return this.scene.map; } diff --git a/packages/l7plot/src/core/plot/index.ts b/packages/l7plot/src/core/plot/index.ts index 71f8005ca..24943f510 100644 --- a/packages/l7plot/src/core/plot/index.ts +++ b/packages/l7plot/src/core/plot/index.ts @@ -1,7 +1,9 @@ +import { Source } from '@antv/l7'; import { Map } from '../map'; import { deepAssign } from '../../utils'; import { TextLayer } from '../../layers/text-layer'; -import { PlotType, PlotOptions, LabelOptions, Source, SourceOptions, Scene, PlotLayerOptions } from '../../types'; +import { PlotType } from '../../types'; +import type { PlotOptions, LabelOptions, SourceOptions, Scene, PlotLayerOptions } from '../../types'; import { LayerGroup } from '../layer/layer-group'; import { MappingSource } from '../../adaptor/source'; import { isEqual } from '@antv/util'; diff --git a/packages/l7plot/src/layers/area-layer/index.ts b/packages/l7plot/src/layers/area-layer/index.ts index a96867ad5..84185d53b 100644 --- a/packages/l7plot/src/layers/area-layer/index.ts +++ b/packages/l7plot/src/layers/area-layer/index.ts @@ -1,5 +1,5 @@ import { uniqueId, clone, isEqual, isUndefined } from '@antv/util'; -import { PolygonLayer, LineLayer } from '@antv/l7-layers'; +import { PolygonLayer, LineLayer } from '@antv/l7'; import { PlotLayer } from '../../core/layer/plot-layer'; import { getDefaultState, mappingLayer } from './adaptor'; import { AreaLayerOptions, AreaLayerSourceOptions } from './types'; diff --git a/packages/l7plot/src/layers/dot-layer/index.ts b/packages/l7plot/src/layers/dot-layer/index.ts index e4ebd6114..b71b0e4a2 100644 --- a/packages/l7plot/src/layers/dot-layer/index.ts +++ b/packages/l7plot/src/layers/dot-layer/index.ts @@ -1,5 +1,5 @@ import { uniqueId } from '@antv/util'; -import { PointLayer } from '@antv/l7-layers'; +import { PointLayer } from '@antv/l7'; import { PlotLayer } from '../../core/layer/plot-layer'; import { mappingLayer } from './adaptor'; import { DotLayerOptions } from './types'; diff --git a/packages/l7plot/src/layers/grid-layer/index.ts b/packages/l7plot/src/layers/grid-layer/index.ts index 91a44c958..c710f9767 100644 --- a/packages/l7plot/src/layers/grid-layer/index.ts +++ b/packages/l7plot/src/layers/grid-layer/index.ts @@ -1,5 +1,5 @@ import { uniqueId } from '@antv/util'; -import { HeatmapLayer as Heatmap } from '@antv/l7-layers'; +import { HeatmapLayer as Heatmap } from '@antv/l7'; import { PlotLayer } from '../../core/layer/plot-layer'; import { mappingLayer } from './adaptor'; import { GridLayerOptions } from './types'; diff --git a/packages/l7plot/src/layers/heatmap-layer/adaptor.ts b/packages/l7plot/src/layers/heatmap-layer/adaptor.ts index e96d7282a..c77b57779 100644 --- a/packages/l7plot/src/layers/heatmap-layer/adaptor.ts +++ b/packages/l7plot/src/layers/heatmap-layer/adaptor.ts @@ -1,4 +1,4 @@ -import { IColorRamp } from '@antv/l7-utils'; +import type { IColorRamp } from '@antv/l7'; import { MappingLayer } from '../../adaptor/layer'; import { HeatmapLayerStyleOptions } from '../../types/layer'; import { ILayer } from '../../types'; diff --git a/packages/l7plot/src/layers/heatmap-layer/index.ts b/packages/l7plot/src/layers/heatmap-layer/index.ts index 94c928af2..93dd891c3 100644 --- a/packages/l7plot/src/layers/heatmap-layer/index.ts +++ b/packages/l7plot/src/layers/heatmap-layer/index.ts @@ -1,5 +1,5 @@ import { uniqueId } from '@antv/util'; -import { HeatmapLayer as Heatmap } from '@antv/l7-layers'; +import { HeatmapLayer as Heatmap } from '@antv/l7'; import { PlotLayer } from '../../core/layer/plot-layer'; import { mappingLayer } from './adaptor'; import { HeatmapLayerOptions } from './types'; diff --git a/packages/l7plot/src/layers/hexbin-layer/index.ts b/packages/l7plot/src/layers/hexbin-layer/index.ts index 2a8dfe48b..6f62da167 100644 --- a/packages/l7plot/src/layers/hexbin-layer/index.ts +++ b/packages/l7plot/src/layers/hexbin-layer/index.ts @@ -1,5 +1,5 @@ import { uniqueId } from '@antv/util'; -import { HeatmapLayer as Heatmap } from '@antv/l7-layers'; +import { HeatmapLayer as Heatmap } from '@antv/l7'; import { PlotLayer } from '../../core/layer/plot-layer'; import { mappingLayer } from './adaptor'; import { HexbinLayerOptions } from './types'; diff --git a/packages/l7plot/src/layers/lines-layer/index.ts b/packages/l7plot/src/layers/lines-layer/index.ts index 23cc030af..6bb5b11ea 100644 --- a/packages/l7plot/src/layers/lines-layer/index.ts +++ b/packages/l7plot/src/layers/lines-layer/index.ts @@ -1,5 +1,5 @@ import { uniqueId } from '@antv/util'; -import { LineLayer } from '@antv/l7-layers'; +import { LineLayer } from '@antv/l7'; import { PlotLayer } from '../../core/layer/plot-layer'; import { mappingLayer } from './adaptor'; import { LinesLayerOptions } from './types'; diff --git a/packages/l7plot/src/layers/prism-layer/index.ts b/packages/l7plot/src/layers/prism-layer/index.ts index 169ae05cc..f5c922e54 100644 --- a/packages/l7plot/src/layers/prism-layer/index.ts +++ b/packages/l7plot/src/layers/prism-layer/index.ts @@ -1,5 +1,5 @@ import { uniqueId } from '@antv/util'; -import { PolygonLayer } from '@antv/l7-layers'; +import { PolygonLayer } from '@antv/l7'; import { PlotLayer } from '../../core/layer/plot-layer'; import { mappingLayer } from './adaptor'; import { PrismLayerOptions } from './types'; diff --git a/packages/l7plot/src/layers/text-layer/index.ts b/packages/l7plot/src/layers/text-layer/index.ts index a5f314893..5dcd5c360 100644 --- a/packages/l7plot/src/layers/text-layer/index.ts +++ b/packages/l7plot/src/layers/text-layer/index.ts @@ -1,5 +1,5 @@ import { uniqueId } from '@antv/util'; -import { PointLayer } from '@antv/l7-layers'; +import { PointLayer } from '@antv/l7'; import { PlotLayer } from '../../core/layer/plot-layer'; import { TextLayerConfig } from '../../types/layer'; import { mappingLayer } from './adaptor'; diff --git a/packages/l7plot/src/plots/choropleth/index.ts b/packages/l7plot/src/plots/choropleth/index.ts index b448abbb1..bbd164250 100644 --- a/packages/l7plot/src/plots/choropleth/index.ts +++ b/packages/l7plot/src/plots/choropleth/index.ts @@ -1,3 +1,4 @@ +import { Source } from '@antv/l7'; import { pick, isEqual } from '@antv/util'; import { Plot } from '../../core/plot'; import { deepAssign } from '../../utils'; @@ -15,7 +16,7 @@ import { GEO_DATA_URL, GEO_AREA_URL, DEFAULT_AREA_GRANULARITY, DEFAULT_OPTIONS } import { AreaLayer } from '../../layers/area-layer'; import { PathLayer } from '../../layers/path-layer'; import { TextLayer } from '../../layers/text-layer'; -import { LabelOptions, LegendOptions, MouseEvent, Source } from '../../types'; +import type { LabelOptions, LegendOptions, MouseEvent } from '../../types'; import { LayerGroup } from '../../core/layer/layer-group'; import { createCountryBoundaryLayer } from './layer'; import { getCacheArea, registerCacheArea } from './cache'; diff --git a/packages/l7plot/src/types/attr.ts b/packages/l7plot/src/types/attr.ts index dee28340f..6fcb60360 100644 --- a/packages/l7plot/src/types/attr.ts +++ b/packages/l7plot/src/types/attr.ts @@ -1,4 +1,4 @@ -import { IAnimateOption, IActiveOption } from '@antv/l7-core'; +import type { IAnimateOption, IActiveOption } from '@antv/l7'; import { ScaleConfig } from './common'; export type Callback = (data: Record) => T | T[]; diff --git a/packages/l7plot/src/types/common.ts b/packages/l7plot/src/types/common.ts index 65fca4370..50c72ad5d 100644 --- a/packages/l7plot/src/types/common.ts +++ b/packages/l7plot/src/types/common.ts @@ -1,4 +1,5 @@ -import { +import type { + Scene, ILayer, ILayerConfig, ISourceCFG, @@ -12,10 +13,10 @@ import { IStatusOptions, ILegendSegmentItem, ILegendClassificaItem, -} from '@antv/l7-core'; -import { Scene } from '@antv/l7-scene'; +} from '@antv/l7'; -export { +export type { + Scene, ILayer, ILayerConfig, ISourceCFG, @@ -28,8 +29,6 @@ export { ILegendClassificaItem, }; -export type { Scene }; - export type ScaleConfig = IScale; export type ScaleConfigMap = IScaleOptions; export type MapStatusOptions = IStatusOptions; diff --git a/packages/l7plot/src/types/control.ts b/packages/l7plot/src/types/control.ts index ec1e0b69b..d3b34850c 100644 --- a/packages/l7plot/src/types/control.ts +++ b/packages/l7plot/src/types/control.ts @@ -1,6 +1,6 @@ -import { PositionType, PositionName } from '@antv/l7-core'; +import type { PositionType, PositionName } from '@antv/l7'; -export { PositionType, PositionName }; +export type { PositionType, PositionName }; /** * ZoomControl diff --git a/packages/l7plot/src/types/layer.ts b/packages/l7plot/src/types/layer.ts index 5fe5025cb..82b060546 100644 --- a/packages/l7plot/src/types/layer.ts +++ b/packages/l7plot/src/types/layer.ts @@ -1,4 +1,4 @@ -import { IColorRamp } from '@antv/l7-utils'; +import type { IColorRamp } from '@antv/l7'; import { BlendType, ILayer, ILayerConfig, Scene } from './common'; import { LabelOptions } from './label'; import { AnimateAttr, ColorAttr, StateAttribute, ShapeAttr, SizeAttr, TextureAttr } from './attr'; diff --git a/packages/l7plot/src/types/legend.ts b/packages/l7plot/src/types/legend.ts index ab1296036..7c2567006 100644 --- a/packages/l7plot/src/types/legend.ts +++ b/packages/l7plot/src/types/legend.ts @@ -1,4 +1,4 @@ -import { PositionName } from '@antv/l7-core'; +import type { PositionName } from '@antv/l7'; import { CategoryLegendCustomContent, CategoryLegendListItem, diff --git a/packages/l7plot/src/types/map.ts b/packages/l7plot/src/types/map.ts index f06d1302e..5aaf93886 100644 --- a/packages/l7plot/src/types/map.ts +++ b/packages/l7plot/src/types/map.ts @@ -1,24 +1,25 @@ -import { Map as MapboxglMap } from 'mapbox-gl'; -import { IAMapInstance, IMapboxInstance } from '@antv/l7-maps/typings'; -import { IStatusOptions, PositionName, ISourceCFG, MapStyle } from '@antv/l7-core'; -import Source from '@antv/l7-source'; -import { TooltipOptions } from './tooltip'; -import { LegendOptions } from './legend'; -import { LayerMenuControlOptions, ScaleControlOptions, ZoomControlOptions } from './control'; -import { GridAggregation } from './attr'; +import type { Map as MapboxglMap } from 'mapbox-gl'; +import type { Map, IStatusOptions, PositionName, ISourceCFG, MapStyle, Source } from '@antv/l7'; +import type { IAMapInstance, IMapboxInstance } from '@antv/l7-maps/typings'; +import type { TooltipOptions } from './tooltip'; +import type { LegendOptions } from './legend'; +import type { LayerMenuControlOptions, ScaleControlOptions, ZoomControlOptions } from './control'; +import type { GridAggregation } from './attr'; -export { MapboxglMap, Source }; +export type { MapboxglMap, Source }; export type StatusOptions = IStatusOptions; +export type MapInstance = Map; export type AMapInstance = AMap.Map & IAMapInstance; export type MapboxInstance = MapboxglMap & IMapboxInstance; -export type MapInstance = AMapInstance | MapboxInstance; /** * 底图类型 */ export enum BaseMapType { + Map = 'map', Amap = 'amap', + AmapV2 = 'amapv2', Mapbox = 'mapbox', } @@ -29,7 +30,7 @@ export type MapConfig = { /** * 底图类型 */ - type?: 'amap' | 'mapbox'; + type?: 'map' | 'amap' | 'amapv2' | 'mapbox'; /** * 地图 */ diff --git a/packages/l7plot/src/types/popup.ts b/packages/l7plot/src/types/popup.ts index 477dbe88c..ae6ea7a1f 100644 --- a/packages/l7plot/src/types/popup.ts +++ b/packages/l7plot/src/types/popup.ts @@ -1,4 +1,4 @@ -import { PositionType } from '@antv/l7-core'; +import type { PositionType } from '@antv/l7'; export type PopupOptions = { position: PositionType; diff --git a/packages/l7plot/src/types/tooltip.ts b/packages/l7plot/src/types/tooltip.ts index fd96da7d6..686fb2af0 100644 --- a/packages/l7plot/src/types/tooltip.ts +++ b/packages/l7plot/src/types/tooltip.ts @@ -1,5 +1,5 @@ import { TooltipListItem, TooltipCustomContent } from '@antv/l7plot-component'; -import { anchorType as TooltipAnchorType } from '@antv/l7-utils'; +import { anchorType as TooltipAnchorType } from '@antv/l7'; import { ILngLat, Event } from './common'; export type TooltipItem = { diff --git a/website/docs/api/plot-api/index.zh.md b/website/docs/api/plot-api/index.zh.md index 48956f946..2eb13beff 100644 --- a/website/docs/api/plot-api/index.zh.md +++ b/website/docs/api/plot-api/index.zh.md @@ -194,7 +194,7 @@ plot.getScene() : Scene; 获取图表的 map 实例。 ```js -plot.getMap() : MapboxInstance | AMapInstance; +plot.getMap() : MapInstance | MapboxInstance | AMapInstance; ``` ### addLayer diff --git a/website/docs/common/attribute/map.zh.md b/website/docs/common/attribute/map.zh.md index cfb0bd720..b0294ff4b 100644 --- a/website/docs/common/attribute/map.zh.md +++ b/website/docs/common/attribute/map.zh.md @@ -8,9 +8,11 @@ `string` optional default: `'amap'` -地图底图类型,支持以下两种类型: +地图底图类型,支持以下类型: +- map: L7 官方地图 - amap: 高德地图 +- amapv2: 高德 V2 地图 - mapbox: Mapbox 地图 地图底图类型不同时,`map` 下面的有的配置项不相同,比如 `maxZoom`,AMap 最大缩放等级 18,Mapbox 最大缩放等级 20。除此之外还有,底图的交互状态配置,`zoomEnable`、`dragEnable`等。各配置项可详见各官网:高德地图 [配置项](https://lbs.amap.com/api/javascript-api/reference/map);Mapbox 地图 [配置项](https://docs.mapbox.com/mapbox-gl-js/api/map/#map-parameters)。 @@ -45,8 +47,9 @@ 初始缩放层级,底图可缩放层级分布为: -- Mapbox (0-24) -- 高德 (2-19) +- Mapbox(0-24) +- 高德(0-20) +- 高德 V2(0-30) #### `map.`minZoom @@ -58,7 +61,7 @@ `number` optional default: `20` -地图最大缩放等级,AMap 最大缩放等级 18,Mapbox 最大缩放等级 20。 +地图最大缩放等级,AMap 最大缩放等级 20,Mapbox 最大缩放等级 24。 #### `map.`style diff --git a/website/docs/manual/faq/index.zh.md b/website/docs/manual/faq/index.zh.md index eb25c8b19..2088239a9 100644 --- a/website/docs/manual/faq/index.zh.md +++ b/website/docs/manual/faq/index.zh.md @@ -11,7 +11,7 @@ order: 2 #### 1. 如何自定义底图样式? -地图底图容器类型支持两种类型:AMap 高德、MapBox。除常见的样式外,如需要自定义底图样式,需到各自厂商的开发者中心自定义底图样式,关于使用详见 API style +地图底图容器类型支持两种三方底图:AMap 高德、MapBox。除常见的样式外,如需要自定义底图样式,需到各自厂商的开发者中心自定义底图样式,关于使用详见 API style ```js { @@ -21,7 +21,7 @@ order: 2 #### 2. 底图可以自定义其它底图服务吗,比如 MapBox、osm、天地图或者自己发布的瓦片、矢量切片地图服务 ? -地图底图容器类型支持两种类型:AMap 高德、MapBox。对于自己发的服务与其它服务,可借助 MapBox 底图容器能力,加载它支持的服务,MapBox 目前支持的服务规范有:瓦片服务(OpenStreetMap 规范)、MapBox 规范矢量瓦片地图服务。 +地图底图容器类型支持两种三方底图:AMap 高德、MapBox。对于自己发的服务与其它服务,可借助 MapBox 底图容器能力,加载它支持的服务,MapBox 目前支持的服务规范有:瓦片服务(OpenStreetMap 规范)、MapBox 规范矢量瓦片地图服务。 #### 3. 图表实例上没有暴露 L7 上的 getZoom 等方法怎么搞?