diff --git a/packages/component/src/control/layer.ts b/packages/component/src/control/layer.ts index 06169079f8..c48c215f21 100644 --- a/packages/component/src/control/layer.ts +++ b/packages/component/src/control/layer.ts @@ -1,17 +1,12 @@ -import { IControlOption, PositionName, PositionType } from '@antv/l7-core'; -import { bindAll, DOM, lnglatDistance } from '@antv/l7-utils'; +import { PositionType } from '@antv/l7-core'; +import { bindAll, DOM } from '@antv/l7-utils'; +import { ILayerControlOption } from '../interface'; import Control from './BaseControl'; -export interface ILayerControlOption extends IControlOption { - collapsed: boolean; - autoZIndex: boolean; - hideSingleBase: boolean; - sortLayers: boolean; - sortFunction: (...args: any[]) => any; -} interface IInputItem extends HTMLInputElement { layerId: string; } + export default class Layers extends Control { private layerControlInputs: any[]; private layers: any[]; diff --git a/packages/component/src/control/logo.ts b/packages/component/src/control/logo.ts index e25251cd35..899d08273f 100644 --- a/packages/component/src/control/logo.ts +++ b/packages/component/src/control/logo.ts @@ -1,6 +1,7 @@ import { IControlOption } from '@antv/l7-core'; import { DOM } from '@antv/l7-utils'; import Control, { PositionType } from './BaseControl'; + export default class Logo extends Control { public getDefault() { return { diff --git a/packages/component/src/control/scale.ts b/packages/component/src/control/scale.ts index fd69532f86..8dd313eded 100644 --- a/packages/component/src/control/scale.ts +++ b/packages/component/src/control/scale.ts @@ -1,13 +1,7 @@ -import { IControlOption } from '@antv/l7-core'; import { bindAll, DOM, lnglatDistance } from '@antv/l7-utils'; - +import { IScaleControlOption } from '../interface'; import Control, { PositionType } from './BaseControl'; -export interface IScaleControlOption extends IControlOption { - maxWidth: number; - metric: boolean; - updateWhenIdle: boolean; - imperial: boolean; -} + export default class Scale extends Control { private mScale: HTMLElement; private iScale: HTMLElement; diff --git a/packages/component/src/control/zoom.ts b/packages/component/src/control/zoom.ts index bbb285c1a0..9dd74120dd 100644 --- a/packages/component/src/control/zoom.ts +++ b/packages/component/src/control/zoom.ts @@ -1,12 +1,7 @@ -import { IControlOption } from '@antv/l7-core'; import { bindAll, DOM } from '@antv/l7-utils'; +import { IZoomControlOption } from '../interface'; import Control, { PositionType } from './BaseControl'; -export interface IZoomControlOption extends IControlOption { - zoomInText: string; - zoomInTitle: string; - zoomOutText: string; - zoomOutTitle: string; -} + export default class Zoom extends Control { private disabled: boolean; private zoomInButton: HTMLElement; diff --git a/packages/component/src/index.ts b/packages/component/src/index.ts index 33e70454ef..a7508dfbf9 100644 --- a/packages/component/src/index.ts +++ b/packages/component/src/index.ts @@ -1,27 +1,16 @@ import Control from './control/BaseControl'; -import Layers, { ILayerControlOption } from './control/layer'; +import Layers from './control/layer'; import Logo from './control/logo'; -import Scale, { IScaleControlOption } from './control/scale'; -import Zoom, { IZoomControlOption } from './control/zoom'; +import Scale from './control/scale'; +import Zoom from './control/zoom'; import Marker from './marker'; -import MarkerLayer, { IMarkerLayerOption } from './markerlayer'; +import MarkerLayer from './marker-layer'; import Popup from './popup'; // 引入样式 // TODO: 使用 Less 或者 Sass,每个组件单独引用自身样式 import './css/l7.css'; -export { - Control, - Logo, - Scale, - IScaleControlOption, - Zoom, - IZoomControlOption, - Layers, - ILayerControlOption, - Marker, - Popup, - MarkerLayer, - IMarkerLayerOption, -}; +export { Control, Logo, Scale, Zoom, Layers, Marker, Popup, MarkerLayer }; + +export * from './interface'; diff --git a/packages/component/src/interface.ts b/packages/component/src/interface.ts new file mode 100644 index 0000000000..9ff8558021 --- /dev/null +++ b/packages/component/src/interface.ts @@ -0,0 +1,41 @@ +import { IControlOption } from '@antv/l7-core'; + +export interface ILayerControlOption extends IControlOption { + collapsed: boolean; + autoZIndex: boolean; + hideSingleBase: boolean; + sortLayers: boolean; + + sortFunction: (...args: any[]) => any; +} + +export interface IScaleControlOption extends IControlOption { + maxWidth: number; + metric: boolean; + updateWhenIdle: boolean; + imperial: boolean; +} + +export interface IZoomControlOption extends IControlOption { + zoomInText: string; + zoomInTitle: string; + zoomOutText: string; + zoomOutTitle: string; +} + +export interface IMarkerStyleOption { + element?: (...args: any[]) => any; + style: { [key: string]: any } | ((...args: any[]) => any); + className: string; + field?: string; + method?: 'sum' | 'max' | 'min' | 'mean'; + radius: number; + maxZoom: number; + minZoom: number; + zoom: number; +} + +export interface IMarkerLayerOption { + cluster: boolean; + clusterOption: Partial; +} diff --git a/packages/component/src/markerlayer.ts b/packages/component/src/marker-layer.ts similarity index 95% rename from packages/component/src/markerlayer.ts rename to packages/component/src/marker-layer.ts index ca7b81b2dd..42aff970d8 100644 --- a/packages/component/src/markerlayer.ts +++ b/packages/component/src/marker-layer.ts @@ -13,26 +13,9 @@ import { merge } from 'lodash'; // @ts-ignore // tslint:disable-next-line:no-submodule-imports import Supercluster from 'supercluster/dist/supercluster'; +import { IMarkerLayerOption, IMarkerStyleOption } from './interface'; import Marker from './marker'; -type CallBack = (...args: any[]) => any; -export interface IMarkerStyleOption { - element?: CallBack; - style: { [key: string]: any } | CallBack; - className: string; - field?: string; - method?: 'sum' | 'max' | 'min' | 'mean'; - radius: number; - maxZoom: number; - minZoom: number; - zoom: number; -} - -export interface IMarkerLayerOption { - cluster: boolean; - clusterOption: Partial; -} - interface IPointFeature { geometry: { type: 'Point';