Skip to content

Commit

Permalink
feat: 完成 OverlayGroup 相关声明
Browse files Browse the repository at this point in the history
  • Loading branch information
xyy94813 committed Mar 12, 2024
1 parent 2f8aed9 commit 8c825fc
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
4 changes: 2 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
- [x] TileLayer.WMTS
- [x] MapboxVectorTileLayer
- [x] LayerGroup
- [ ] 覆盖物
- [x] 覆盖物
- [x] Marker
- [x] Text
- [x] Icon
Expand All @@ -49,7 +49,7 @@
- [x] Ellipse
- [x] Rectangle
- [x] GeoJSON
- [ ] OverlayGroup
- [x] OverlayGroup
- [x] 地图控件
- [x] Control
- [x] Scale
Expand Down
6 changes: 6 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ import type {
} from './overlays/Rectangle';

import type { LayerGroup, LayerGroupEventType } from './layers/LayerGroup';
import type {
OverlayGroup,
OverlayGroupEventType,
} from './overlays/OverlayGroup';

import type { Control, CommonControlConfig } from './controls/Control.d.ts';
import type { ControlBar, ControlBarConfig } from './controls/ControlBar.d.ts';
Expand Down Expand Up @@ -235,6 +239,8 @@ declare namespace AMap {
// group
LayerGroup,
LayerGroupEventType,
OverlayGroup,
OverlayGroupEventType,

// 地图控件
Control,
Expand Down
48 changes: 48 additions & 0 deletions types/overlays/OverlayGroup.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import type Event from '../common/Event';
import type Map from '../Map';
import type Overlay from './Overlay';

export type OverlayGroupEventType = string;

/**
* OverlayGroup 用来包装其它图层类的实例,对实例集合做批量操作,避免开发者对多个需要设置同样属性的图层实例做循环处理。
*
* @docs https://lbs.amap.com/api/javascript-api-v2/documentation#layergroup
*/
export declare class OverlayGroup<
OverlayType extends Overlay | OverlayGroup = any,
> extends Event<OverlayGroupEventType> {
constructor(layers?: OverlayType[]);
/** 添加到地图上面 */
setMap(map?: Map): this;
/** 添加单个覆盖物到集合中,不支持添加重复的覆盖物 */
addOverlay(overlay: OverlayType): void;
/** 添加覆盖物数组到集合中,不支持添加重复的覆盖物 */
addOverlays(overlays: OverlayType[]): void;
/** 返回当前集合中所有的覆盖物 */
getOverlays(): OverlayType[];
/** 判断传入的覆盖物实例是否在集合中 */
hasOverlay(overlay: OverlayType): boolean;
/** 从集合中删除传入的覆盖物实例 */
removeOverlay(overlay: OverlayType): void;
/** 从集合中删除传入的覆盖物实例数组 */
removeOverlays(overlays: OverlayType[]): void;
/** 清空集合 */
clearOverlays(): void;
/** 对集合中的覆盖物做迭代操作 */
eachOverlay(
fn?: (
overlay: OverlayType,
index: number,
collections: OverlayType[],
) => any,
): void;
/** 设置图层隐藏 */
hide(): void;
/** 设置图层可见 */
show(): void;
/** 修改图层属性(包括线样式、样色等等) */
setOptions(opts: any): void;
}

export default OverlayGroup;

0 comments on commit 8c825fc

Please sign in to comment.