From 1e38dbd503c11d4d0ceba7da1a3812dc7cdb449e Mon Sep 17 00:00:00 2001 From: breeze9527 Date: Thu, 21 Mar 2019 10:16:51 +0800 Subject: [PATCH] [amap-js-api] Add comments --- types/amap-js-api/array-bounds.d.ts | 5 + types/amap-js-api/bounds.d.ts | 27 ++ types/amap-js-api/browser.d.ts | 141 ++++++++ types/amap-js-api/common.d.ts | 9 + types/amap-js-api/convert-from.d.ts | 12 + types/amap-js-api/dom-util.d.ts | 69 +++- types/amap-js-api/event.d.ts | 57 ++- types/amap-js-api/geometry-util.d.ts | 118 ++++-- types/amap-js-api/layer/building.d.ts | 24 ++ types/amap-js-api/layer/flexible.d.ts | 18 + types/amap-js-api/layer/layer.d.ts | 36 ++ types/amap-js-api/layer/layerGroup.d.ts | 37 +- types/amap-js-api/layer/massMarks.d.ts | 52 +++ types/amap-js-api/layer/mediaLayer.d.ts | 59 +++ types/amap-js-api/layer/tileLayer.d.ts | 54 +++ types/amap-js-api/layer/wms.d.ts | 27 ++ types/amap-js-api/layer/wmts.d.ts | 27 ++ types/amap-js-api/lngLat.d.ts | 28 ++ types/amap-js-api/map.d.ts | 381 ++++++++++++++++++++ types/amap-js-api/overlay/bezierCurve.d.ts | 15 +- types/amap-js-api/overlay/circle.d.ts | 35 ++ types/amap-js-api/overlay/circleMarker.d.ts | 3 + types/amap-js-api/overlay/contextMenu.d.ts | 29 +- types/amap-js-api/overlay/ellipse.d.ts | 22 ++ types/amap-js-api/overlay/geoJSON.d.ts | 29 ++ types/amap-js-api/overlay/icon.d.ts | 23 ++ types/amap-js-api/overlay/infoWindow.d.ts | 61 ++++ types/amap-js-api/overlay/marker.d.ts | 194 +++++++++- types/amap-js-api/overlay/markerShape.d.ts | 4 + types/amap-js-api/overlay/overlay.d.ts | 38 ++ types/amap-js-api/overlay/overlayGroup.d.ts | 54 ++- types/amap-js-api/overlay/pathOverlay.d.ts | 30 ++ types/amap-js-api/overlay/polygon.d.ts | 46 +++ types/amap-js-api/overlay/polyline.d.ts | 73 ++++ types/amap-js-api/overlay/rectangle.d.ts | 22 ++ types/amap-js-api/overlay/shapeOverlay.d.ts | 50 +++ types/amap-js-api/overlay/text.d.ts | 22 ++ types/amap-js-api/pixel.d.ts | 19 + types/amap-js-api/size.d.ts | 15 + types/amap-js-api/util.d.ts | 59 ++- types/amap-js-api/view2D.d.ts | 16 + 41 files changed, 1982 insertions(+), 58 deletions(-) diff --git a/types/amap-js-api/array-bounds.d.ts b/types/amap-js-api/array-bounds.d.ts index 419d8e4b1d..3e0145e049 100644 --- a/types/amap-js-api/array-bounds.d.ts +++ b/types/amap-js-api/array-bounds.d.ts @@ -2,7 +2,12 @@ declare namespace AMap { class ArrayBounds { constructor(bounds: LocationValue[]); bounds: LngLat[]; + /** + * 判断传入的点是否在ArrayBounds内 + * @param point 目标点 + */ contains(point: LocationValue): boolean; + // internal toBounds(): Bounds; getCenter(): LngLat; diff --git a/types/amap-js-api/bounds.d.ts b/types/amap-js-api/bounds.d.ts index 63e880fe65..f594969292 100644 --- a/types/amap-js-api/bounds.d.ts +++ b/types/amap-js-api/bounds.d.ts @@ -1,12 +1,39 @@ declare namespace AMap { class Bounds { + /** + * 地物对象的经纬度矩形范围。 + * @param southWest 西南角经纬度 + * @param northEast 东北角经纬度 + */ constructor(southWest: LngLat, northEast: LngLat); + /** + * 指定点坐标是否在矩形范围内 + * @param point 制定坐标 + */ contains(point: LocationValue): boolean; + /** + * 获取当前Bounds的中心点经纬度坐标 + */ getCenter(): LngLat; + /** + * 获取西南角坐标 + */ getSouthWest(): LngLat; + /** + * 获取东南角坐标 + */ getSouthEast(): LngLat; + /** + * 获取东北角坐标 + */ getNorthEast(): LngLat; + /** + * 获取西北角坐标 + */ getNorthWest(): LngLat; + /** + * 以字符串形式返回地物对象的矩形范围 + */ toString(): string; } } diff --git a/types/amap-js-api/browser.d.ts b/types/amap-js-api/browser.d.ts index 71bfaa8fea..26b3956aa1 100644 --- a/types/amap-js-api/browser.d.ts +++ b/types/amap-js-api/browser.d.ts @@ -1,51 +1,192 @@ declare namespace AMap { namespace Browser { + /** + * 当前浏览器userAgent + */ const ua: string; + /** + * 是否移动设备 + */ const mobile: boolean; + /** + * 平台类型,如:'windows'、'mac'、'ios'、'android'、'other' + */ const plat: 'android' | 'ios' | 'windows' | 'mac' | 'other'; + /** + * 是否mac设备 + */ const mac: boolean; + /** + * 是否windows设备 + */ const windows: boolean; + /** + * 是否iOS设备 + */ const ios: boolean; + /** + * 是否iPad + */ const iPad: boolean; + /** + * 是否iPhone + */ const iPhone: boolean; + /** + * 是否安卓设备 + */ const android: boolean; + /** + * 是否安卓4以下系统 + */ const android23: boolean; + /** + * 是否Chrome浏览器 + */ const chrome: boolean; + /** + * 是否火狐浏览器 + */ const firefox: boolean; + /** + * 是否Safari浏览器 + */ const safari: boolean; + /** + * 是否微信 + */ const wechat: boolean; + /** + * 是否UC浏览器 + */ const uc: boolean; + /** + * 是否QQ或者QQ浏览器 + */ const qq: boolean; + /** + * 是否IE + */ const ie: boolean; + /** + * 是否IE6 + */ const ie6: boolean; + /** + * 是否IE7 + */ const ie7: boolean; + /** + * 是否IE8 + */ const ie8: boolean; + /** + * 是否IE9 + */ const ie9: boolean; + /** + * 是否IE10 + */ const ie10: boolean; + /** + * 是否IE11 + */ const ie11: boolean; + /** + * 是否Edge浏览器 + */ const edge: boolean; + /** + * 是否IE9以下 + */ const ielt9: boolean; + /** + * 是否百度浏览器 + */ const baidu: boolean; + /** + * 是否支持LocaStorage + */ const isLocalStorage: boolean; + /** + * 是否支持Geolocation + */ const isGeolocation: boolean; + /** + * 是否Webkit移动浏览器 + */ const mobileWebkit: boolean; + /** + * 是否支持Css3D的Webkit移动端浏览器 + */ const mobileWebkit3d: boolean; + /** + * 是否Opera移动浏览器 + */ const mobileOpera: boolean; + /** + * 是否高清屏幕,devicePixelRatio>1 + */ const retina: boolean; + /** + * 是否触屏 + */ const touch: boolean; + /** + * 是否msPointer设备 + */ const msPointer: boolean; + /** + * 是否pointer设备 + */ const pointer: boolean; + /** + * 是否webkit浏览器 + */ const webkit: boolean; + /** + * 是否支持Css3D的ie浏览器 + */ const ie3d: boolean; + /** + * 是否支持Css3D的Webkit浏览器 + */ const webkit3d: boolean; + /** + * 是否支持Css3D的gecko浏览器 + */ const gecko3d: boolean; + /** + * 是否支持Css3D的opera浏览器 + */ const opera3d: boolean; + /** + * 是否支持Css3D的浏览器 + */ const any3d: boolean; + /** + * 是否支持canvas + */ const isCanvas: boolean; + /** + * 是否支持svg + */ const isSvg: boolean; + /** + * 是否支持vml + */ const isVML: boolean; + /** + * 是否支持WebWorker + */ const isWorker: boolean; + /** + * 是否支持WebSocket + */ const isWebsocket: boolean; + /** + * 判断是否支持webgl + */ function isWebGL(): boolean; } } diff --git a/types/amap-js-api/common.d.ts b/types/amap-js-api/common.d.ts index 3d51dc719e..8b442ad0a3 100644 --- a/types/amap-js-api/common.d.ts +++ b/types/amap-js-api/common.d.ts @@ -9,8 +9,17 @@ declare namespace AMap { : V extends undefined ? {} : { value: V }); type MapsEvent = Event; diff --git a/types/amap-js-api/convert-from.d.ts b/types/amap-js-api/convert-from.d.ts index 9fe1f1e76d..61f83f9b94 100644 --- a/types/amap-js-api/convert-from.d.ts +++ b/types/amap-js-api/convert-from.d.ts @@ -1,12 +1,24 @@ declare namespace AMap { namespace convertFrom { interface Result { + /** + * 成功状态文字描述 + */ info: string; // 'ok' + /** + * 高德坐标集合 + */ locations: LngLat[]; } type Type = 'gps' | 'baidu' | 'mapbar'; type SearchStatus = 'complete' | 'error'; } + /** + * 为坐标转换类,支持将其他坐标系的坐标点转换为高德坐标系。 + * @param lnglat 待转换坐标 + * @param type 用于说明是哪个服务商的坐标 + * @param callback 转换完成后的回调函数 + */ function convertFrom( lnglat: LocationValue | LocationValue[], type: convertFrom.Type | null, diff --git a/types/amap-js-api/dom-util.d.ts b/types/amap-js-api/dom-util.d.ts index d83a2ca69a..e39793f006 100644 --- a/types/amap-js-api/dom-util.d.ts +++ b/types/amap-js-api/dom-util.d.ts @@ -1,31 +1,78 @@ declare namespace AMap { namespace DomUtil { + /** + * 获取DOM元素的大小 + * @param dom DOM元素 + */ function getViewport(dom: HTMLElement): Size; - + /** + * 获取DOM元素距离窗口左上角的距离 + * @param dom DOM元素 + */ function getViewportOffset(dom: HTMLElement): Pixel; - + /** + * 在parentNode内部创建一个className类名的tagName元素 + * @param tagName 标签名称 + * @param parent 父节点 + * @param className 类名 + */ function create( tagName: K, parent?: HTMLElement, className?: string ): HTMLElementTagNameMap[K]; - + /** + * 给DOM元素设置为className样式 + * @param dom DOM元素 + * @param className 类名 + */ function setClass(dom: HTMLElement, className?: string): void; - + /** + * DOM元素是否包含className + * @param dom DOM元素 + * @param className 类名 + */ function hasClass(dom: HTMLElement, className: string): boolean; - + /** + * 给DOM元素添加一个className + * @param dom DOM元素 + * @param className 类名 + */ function addClass(dom: HTMLElement, className: string): void; - + /** + * 给DOM元素删除一个className + * @param dom DOM元素 + * @param className 类名 + */ function removeClass(dom: HTMLElement, className: string): void; - + /** + * 给DOM元素设定一个透明度 + * @param dom DOM元素 + * @param opacity 透明度(0-1) + */ function setOpacity(dom: HTMLElement, opacity: number): void; - + /** + * 给DOM元素旋转一个角度,以center为中心,center以元素左上角为坐标原点 + * @param dom DOM元素 + * @param deg 旋转角度 + * @param origin 旋转中心 + */ function rotate(dom: HTMLElement, deg: number, origin?: { x: number, y: number }): void; - + /** + * 给DOM元素删除一组样式,Object同样式表 + * @param dom DOM元素 + * @param style 样式 + */ function setCss(dom: HTMLElement | HTMLElement[], style: Partial): typeof DomUtil; // this - + /** + * 清空DOM元素 + * @param dom DOM元素 + */ function empty(dom: HTMLElement): void; - + /** + * 将DOM元素从父节点删除 + * @param dom DOM元素 + */ function remove(dom: HTMLElement): void; } } diff --git a/types/amap-js-api/event.d.ts b/types/amap-js-api/event.d.ts index d8ff5753c9..d90ee4c720 100644 --- a/types/amap-js-api/event.d.ts +++ b/types/amap-js-api/event.d.ts @@ -1,5 +1,13 @@ declare namespace AMap { abstract class EventEmitter { + /** + * 注册事件 + * @param eventName 事件名称 + * @param handler 事件回调函数 + * @param context 事件回调中的上下文 + * @param once 触发一次 + * @param unshift 更改事件顺序 + */ on( eventName: string, // tslint:disable-next-line:no-unnecessary-generics @@ -8,14 +16,23 @@ declare namespace AMap { once?: boolean, unshift?: boolean ): this; - + /** + * 移除事件绑定 + * @param eventName 事件名称 + * @param handler 事件功能函数 + * @param context 事件上下文 + */ off( eventName: string, // tslint:disable-next-line handler: ((this: C, event: E) => void) | 'mv', context?: C ): this; - + /** + * 触发事件 + * @param eventName 事件名称 + * @param data 事件数据 + */ emit(eventName: string, data?: any): this; } @@ -23,7 +40,13 @@ declare namespace AMap { interface EventListener { type: T; } - + /** + * 注册DOM对象事件 + * @param instance 需注册事件的DOM对象 + * @param eventName 事件名称 + * @param handler 事件功能函数 + * @param context 事件上下文 + */ function addDomListener( // tslint:disable-next-line: no-unnecessary-generics instance: HTMLElementTagNameMap[N], @@ -31,7 +54,13 @@ declare namespace AMap { handler: (this: C, event: HTMLElementEventMap[E]) => void, context?: C ): EventListener<0>; - + /** + * 给对象注册事件 + * @param instance 需注册事件的对象 + * @param eventName 事件名称 + * @param handler 事件功能函数 + * @param context 事件上下文 + */ function addListener( // tslint:disable-next-line: no-unnecessary-generics instance: I, @@ -41,7 +70,13 @@ declare namespace AMap { // tslint:disable-next-line: no-unnecessary-generics context?: C ): EventListener<1>; - + /** + * 给对象注册一次性事件 + * @param instance 需注册事件的对象 + * @param eventName 事件名称 + * @param handler 事件功能函数 + * @param context 事件上下文 + */ function addListenerOnce( // tslint:disable-next-line: no-unnecessary-generics instance: I, @@ -51,9 +86,17 @@ declare namespace AMap { // tslint:disable-next-line: no-unnecessary-generics context?: C ): EventListener<1>; - + /** + * 删除事件 + * @param listener 侦听器 + */ function removeListener(listener: EventListener<0 | 1>): void; - + /** + * 触发非DOM事件 + * @param instance 触发对象 + * @param eventName 事件名称 + * @param data 事件数据 + */ function trigger(instance: EventEmitter, eventName: string, data?: any): void; } } diff --git a/types/amap-js-api/geometry-util.d.ts b/types/amap-js-api/geometry-util.d.ts index 03f6800088..c8a5eae2e9 100644 --- a/types/amap-js-api/geometry-util.d.ts +++ b/types/amap-js-api/geometry-util.d.ts @@ -1,106 +1,176 @@ declare namespace AMap { namespace GeometryUtil { + /** + * 计算两个经纬度点之间的实际距离 + */ function distance( point1: LocationValue, point2: LocationValue | LocationValue[] ): number; - + /** + * 计算一个经纬度路径围成区域的实际面积 + */ function ringArea(ring: LocationValue[]): number; - + /** + * 判断一个经纬度路径是否为顺时针 + */ function isClockwise(path: LocationValue[]): boolean; - + /** + * 计算一个经纬度路径的实际长度 + */ function distanceOfLine(line: LocationValue[]): number; - + /** + * 计算两个经纬度面的交叉区域 + */ function ringRingClip( ring1: LocationValue[], ring2: LocationValue[] ): Array<[number, number]>; - + /** + * 判断两个经纬度面是否交叉 + */ function doesRingRingIntersect( ring1: LocationValue[], ring2: LocationValue[] ): boolean; - + /** + * 判断经纬度路径和经纬度面是否交叉 + */ function doesLineRingIntersect( line: LocationValue[], ring: LocationValue[] ): boolean; - + /** + * 判断两个经纬度路径是否相交 + */ function doesLineLineIntersect( line1: LocationValue[], line2: LocationValue[] ): boolean; - + /** + * 判断线段和多个环是否相交 + */ function doesSegmentPolygonIntersect( point1: LocationValue, point2: LocationValue, polygon: LocationValue[][] ): boolean; - + /** + * 判断线段和一个环是否相交 + */ function doesSegmentRingIntersect( point1: LocationValue, point2: LocationValue, ring: LocationValue[] ): boolean; - + /** + * 判断线段和一个路径是否相交 + */ function doesSegmentLineIntersect( point1: LocationValue, point2: LocationValue, line: LocationValue[] ): boolean; - + /** + * 判断两个线段是否相交 + */ function doesSegmentsIntersect( point1: LocationValue, point2: LocationValue, point3: LocationValue, point4: LocationValue ): boolean; - + /** + * 判断点是否在环内 + */ function isPointInRing(point: LocationValue, ring: LocationValue[]): boolean; - + /** + * 判断环是否在另一个环内 + */ function isRingInRing(ring1: LocationValue[], ring2: LocationValue[]): boolean; - + /** + * 判断点是否在多个环组成区域内 + */ function isPointInPolygon(point: LocationValue, polygon: LocationValue[][]): boolean; - + /** + * 判断点是否在多个环组成区域内 + */ function makesureClockwise(path: Array<[number, number]>): Array<[number, number]>; - + /** + * 将一个路径变为逆时针 + */ function makesureAntiClockwise(path: Array<[number, number]>): Array<[number, number]>; - + /** + * 计算P2P3上距离P1最近的点 + * @param point1 P1 + * @param point2 P2 + * @param point3 P3 + */ function closestOnSegment( point1: LocationValue, point2: LocationValue, point3: LocationValue ): [number, number]; - + /** + * 计算line上距离P最近的点 + */ function closestOnLine(point: LocationValue, line: LocationValue[]): [number, number]; - + /** + * 计算P2P3到P1的距离 + * @param point1 P1 + * @param point2 P2 + * @param point3 P3 + */ function distanceToSegment( point1: LocationValue, point2: LocationValue, point3: LocationValue ): number; - + /** + * 计算P到line的距离 + */ function distanceToLine(point: LocationValue, line: LocationValue[]): number; - + /** + * 判断P1是否在P2P3上 + * @param point1 P1 + * @param point2 P2 + * @param point3 P3 + * @param tolerance 误差范围 + */ function isPointOnSegment( point1: LocationValue, point2: LocationValue, point3: LocationValue, tolerance?: number ): boolean; - + /** + * 判断P是否在line上 + * @param point 点P + * @param line 线 + * @param tolerance 误差范围 + */ function isPointOnLine( point: LocationValue, line: LocationValue[], tolerance?: number ): boolean; - + /** + * 判断P是否在ring的边上 + * @param point 点P + * @param ring 环 + * @param tolerance 误差范围 + */ function isPointOnRing( point: LocationValue, ring: LocationValue[], tolerance?: number ): boolean; - + /** + * 判断P是否在多个ring的边上 + * @param point 点P + * @param polygon 多边形 + * @param tolerance 误差范围 + */ function isPointOnPolygon( point: LocationValue, polygon: LocationValue[][], diff --git a/types/amap-js-api/layer/building.d.ts b/types/amap-js-api/layer/building.d.ts index 30dd7c4092..1b7426e28d 100644 --- a/types/amap-js-api/layer/building.d.ts +++ b/types/amap-js-api/layer/building.d.ts @@ -1,11 +1,27 @@ declare namespace AMap { namespace Buildings { interface Options extends Layer.Options { + /** + * 可见级别范围 + */ zooms?: [number, number]; + /** + * 不透明度 + */ opacity?: number; + /** + * 高度比例系数,可控制3D视图下的楼块高度 + */ heightFactor?: number; + /** + * 是否可见 + */ visible?: boolean; + /** + * 层级 + */ zIndex?: number; + // inner merge?: boolean; sort?: boolean; @@ -24,7 +40,15 @@ declare namespace AMap { } class Buildings extends Layer { + /** + * 楼块图层,单独展示矢量化的楼块图层 + * @param opts 图层选项 + */ constructor(opts?: Buildings.Options); + /** + * 按区域设置楼块的颜色 + * @param style 颜色设置 + */ setStyle(style: Buildings.Style): void; } } diff --git a/types/amap-js-api/layer/flexible.d.ts b/types/amap-js-api/layer/flexible.d.ts index bdb4001a7c..d91970dc31 100644 --- a/types/amap-js-api/layer/flexible.d.ts +++ b/types/amap-js-api/layer/flexible.d.ts @@ -2,6 +2,14 @@ declare namespace AMap { namespace TileLayer { namespace Flexible { interface Options extends TileLayer.Options { + /** + * 创建切片回调 + * @param x 横坐标 + * @param y 纵坐标 + * @param z 层级 + * @param success 成功回调 + * @param fail 失败回调 + */ createTile?( x: number, y: number, @@ -9,11 +17,21 @@ declare namespace AMap { success: (tile: HTMLImageElement | HTMLCanvasElement) => void, fail: () => void ): void; + /** + * 内存中缓存的切片的数量上限 + */ cacheSize?: number; + /** + * 是否显示 + */ visible?: boolean; } } class Flexible extends TileLayer { + /** + * 灵活切片图层 + * @param options 图层选项 + */ constructor(options?: Flexible.Options); } } diff --git a/types/amap-js-api/layer/layer.d.ts b/types/amap-js-api/layer/layer.d.ts index 8f35d949fd..64714bc68f 100644 --- a/types/amap-js-api/layer/layer.d.ts +++ b/types/amap-js-api/layer/layer.d.ts @@ -1,20 +1,56 @@ declare namespace AMap { namespace Layer { interface Options { + /** + * 所属的地图对象 + */ map?: Map; } } abstract class Layer extends EventEmitter { + /** + * 图层获取DOM节点 + */ getContainer(): HTMLDivElement | undefined; + /** + * 获取图层缩放范围 + */ getZooms(): [number, number]; + /** + * 设置透明度 + * @param alpha 透明度 + */ setOpacity(alpha: number): void; + /** + * 设置透明度 + */ getOpacity(): number; + /** + * 显示图层 + */ show(): void; + /** + * 隐藏图层 + */ hide(): void; + /** + * 设置图层所属地图 + * @param map map对象 + */ setMap(map?: Map | null): void; + /** + * 获取图层所属地图 + */ getMap(): Map | null | undefined; + /** + * 设置图层的层级 + * @param index 层级 + */ setzIndex(index: number): void; + /** + * 获取图层的层级 + */ getzIndex(): number; } } diff --git a/types/amap-js-api/layer/layerGroup.d.ts b/types/amap-js-api/layer/layerGroup.d.ts index 4cc463eef7..6a07c8fc72 100644 --- a/types/amap-js-api/layer/layerGroup.d.ts +++ b/types/amap-js-api/layer/layerGroup.d.ts @@ -1,14 +1,49 @@ declare namespace AMap { class LayerGroup extends Layer { + /** + * 图层集合 + * @param layers 集合中的图层 + */ constructor(layers: L | L[]); + /** + * 添加单个图层到集合中,不支持添加重复的图层 + * @param layer 图层 + */ addLayer(layer: L | L[]): this; + /** + * 添加图层数组到集合中,不支持添加重复的图层 + * @param layers 图层数组 + */ addLayers(layers: L | L[]): this; + /** + * 返回当前集合中所有的图层 + */ getLayers(): L[]; getLayer(finder: (this: null, item: L, index: number, list: L[]) => boolean): L | null; + /** + * 判断传入的图层实例是否在集合中 + * @param layer 目标图层 + */ hasLayer(layer: L | ((this: null, item: L, index: number, list: L[]) => boolean)): boolean; + /** + * 从集合中删除传入的图层实例 + * @param layer 图层 + */ removeLayer(layer: L | L[]): this; - removeLayers(layer: L | L[]): this; + /** + * 从集合中删除传入的图层实例数组 + * @param layers 图层数组 + */ + removeLayers(layers: L | L[]): this; + /** + * 清空集合 + */ clearLayers(): this; + /** + * 对集合中的图层做迭代操作 + * @param iterator 迭代回调 + * @param context 执行上下文 + */ eachLayer(iterator: (this: C, layer: L, index: number, list: L[]) => void, context?: C): void; // overwrite diff --git a/types/amap-js-api/layer/massMarks.d.ts b/types/amap-js-api/layer/massMarks.d.ts index 1ab5464a5b..963f7e2ec6 100644 --- a/types/amap-js-api/layer/massMarks.d.ts +++ b/types/amap-js-api/layer/massMarks.d.ts @@ -12,21 +12,51 @@ declare namespace AMap { } interface Style { + /** + * 图标显示位置偏移量,以图标的左上角为基准点(0,0)点 + */ anchor: Pixel; + /** + * 图标的地址 + */ url: string; + /** + * 图标的尺寸 + */ size: Size; + /** + * 旋转角度 + */ rotation?: number; } type UIEvent = Event ? D : Data; }>; interface Options extends Layer.Options { + /** + * 显示层级 + */ zIndex?: number; + /** + * 指针样式 + */ cursor?: string; + /** + * 是否在拖拽缩放过程中实时重绘 + */ alwayRender?: boolean; + /** + * 设置点的样式 + */ style: Style | Style[]; // rejectMapMask } @@ -37,11 +67,33 @@ declare namespace AMap { } class MassMarks extends Layer { + /** + * 海量点类,利用该类可同时在地图上展示万级别的点 + * @param data 点对象数组或url + * @param opts 选项 + */ constructor(data: D[] | string, opts: MassMarks.Options); + /** + * 设置显示样式 + * @param style 样式设置 + */ setStyle(style: MassMarks.Style | MassMarks.Style[]): void; + /** + * 获取显示样式 + */ getStyle(): MassMarks.Style | MassMarks.Style[]; + /** + * 设置数据集 + * @param data 数据集 + */ setData(data: D[] | string): void; + /** + * 获取数据集 + */ getData(): Array> & { lnglat: LngLat }>; + /** + * 清除海量点 + */ clear(): void; } } diff --git a/types/amap-js-api/layer/mediaLayer.d.ts b/types/amap-js-api/layer/mediaLayer.d.ts index a38f5ba025..43fee214bb 100644 --- a/types/amap-js-api/layer/mediaLayer.d.ts +++ b/types/amap-js-api/layer/mediaLayer.d.ts @@ -1,35 +1,94 @@ declare namespace AMap { namespace MediaLayer { interface Options extends Layer.Options { + /** + * 显示范围 + */ bounds?: Bounds; + /** + * 是否可见 + */ visible?: boolean; + /** + * 缩放范围 + */ zooms?: [number, number]; + /** + * 透明度 + */ opacity?: number; } } abstract class MediaLayer extends Layer { + /** + * @param options 图层选项 + */ constructor(options?: MediaLayer.Options); + /** + * 设置显示范围 + * @param bounds 显示范围 + */ setBounds(bounds: Bounds): void; + /** + * 获取显示的范围 + */ getBounds(): Bounds; + /** + * 设置图层选项 + * @param options 图层选项 + */ setOptions(options: Partial): void; + /** + * 获取图层选项 + */ getOptions(): Partial; + /** + * 获取元素 + */ getElement(): E | null; } + /** + * 图片图层 + */ class ImageLayer extends MediaLayer { + /** + * 修改Image的Url + * @param url url + */ setImageUrl(url: string): void; + /** + * 返回Image的Url + */ getImageUrl(): string | undefined; } class VideoLayer extends MediaLayer { + /** + * 修改Video的Url + * @param source url + */ setVideoUrl(source: string | string[]): void; + /** + * 返回Video的Url + */ getVideoUrl(): string | string[] | undefined; } class CanvasLayer extends MediaLayer { + /** + * 修改显示的Canvas + * @param canvas Canvas对象 + */ setCanvas(canvas: HTMLCanvasElement): void; + /** + * 返回Canvas对象 + */ getCanvas(): HTMLCanvasElement | undefined; + /** + * 当canvas的内容发生改变是用于刷新图层 + */ reFresh(): void; } } diff --git a/types/amap-js-api/layer/tileLayer.d.ts b/types/amap-js-api/layer/tileLayer.d.ts index 7576a70664..1a146b964c 100644 --- a/types/amap-js-api/layer/tileLayer.d.ts +++ b/types/amap-js-api/layer/tileLayer.d.ts @@ -5,33 +5,87 @@ declare namespace AMap { } interface Options extends Layer.Options { + /** + * 切片大小 + */ tileSize?: number; + /** + * 切片取图地址(自1.3版本起,该属性与getTileUrl属性合并) + */ tileUrl?: string; + /** + * 取图错误时的代替地址 + */ errorUrl?: string; + /** + * 获取图块取图地址 + */ getTileUrl?: string | ((x: number, y: number, level: number) => string); + /** + * 图层叠加的顺序值 + */ zIndex?: number; + /** + * 图层的透明度 + */ opacity?: number; + /** + * 支持的缩放级别范围 + */ zooms?: [number, number]; + /** + * 是否在高清屏下进行清晰度适配 + */ detectRetina?: boolean; } + /** + * 卫星图层 + */ class Satellite extends TileLayer { } + /** + * 路网图层 + */ class RoadNet extends TileLayer { } namespace Traffic { interface Options extends TileLayer.Options { + /** + * 是否设置可以自动刷新实时路况信息 + */ autoRefresh?: boolean; + /** + * 设置刷新间隔时长 + */ interval?: number; } } class Traffic extends TileLayer { + /** + * 实时交通图层 + * @param options 图层选项 + */ constructor(options?: Traffic.Options); } } class TileLayer extends Layer { + /** + * 切片图层 + * @param options 图层选项 + */ constructor(options?: TileLayer.Options); + /** + * 获取当前图层所有切片号 + */ getTiles(): string[]; + /** + * 重新加载此图层 + */ reload(): void; + /** + * 设置图层的取图地址 + * @param url 取图地址 + */ setTileUrl(url: string | ((x: number, y: number, level: number) => string)): void; } } diff --git a/types/amap-js-api/layer/wms.d.ts b/types/amap-js-api/layer/wms.d.ts index c4561ddf14..043975d856 100644 --- a/types/amap-js-api/layer/wms.d.ts +++ b/types/amap-js-api/layer/wms.d.ts @@ -13,16 +13,43 @@ declare namespace AMap { ELEVATION?: string; } interface Options extends Flexible.Options { + /** + * wms服务的url地址 + */ url: string; + /** + * OGC标准的WMS地图服务的GetMap接口的参数 + */ params: Params; + /** + * 地图级别切换时,不同级别的图片是否进行混合 + */ blend?: boolean; } } class WMS extends Flexible { + /** + * WMS图层 + * @param options 图层选项 + */ constructor(options: WMS.Options); + /** + * 设置wms服务地址 + * @param url 服务地址 + */ setUrl(url: string): void; + /** + * 返回wms服务地址 + */ getUrl(): string; + /** + * 设置OGC标准的WMS getMap接口的参数 + * @param params 接口参数 + */ setParams(params: WMS.Params): void; + /** + * 返回OGC标准的WMS getMap接口的参数 + */ getParams(): WMS.Params; } } diff --git a/types/amap-js-api/layer/wmts.d.ts b/types/amap-js-api/layer/wmts.d.ts index 5d85e5df48..7a122dd6b9 100644 --- a/types/amap-js-api/layer/wmts.d.ts +++ b/types/amap-js-api/layer/wmts.d.ts @@ -8,17 +8,44 @@ declare namespace AMap { Format?: string; } interface Options extends Flexible.Options { + /** + * wmts服务的url地址 + */ url: string; + /** + * OGC标准的WMTS地图服务的GetTile接口的参数 + */ params: Params; + /** + * 地图级别切换时,不同级别的图片是否进行混合 + */ blend?: boolean; } } class WMTS extends Flexible { + /** + * WMTS图层 + * @param options 图层选项 + */ constructor(options: WMTS.Options); + /** + * 设置wmts服务地址 + * @param url 服务地址 + */ setUrl(url: string): void; + /** + * 返回wmts服务地址 + */ getUrl(): string; + /** + * 设置OGC标准的WMTS getTile接口的参数 + * @param params 接口参数 + */ setParams(params: WMTS.Params): void; + /** + * 返回OGC标准的WMTS getTile接口的参数 + */ getParams(): WMTS.Params; } } diff --git a/types/amap-js-api/lngLat.d.ts b/types/amap-js-api/lngLat.d.ts index 4247002b2b..f649a78de8 100644 --- a/types/amap-js-api/lngLat.d.ts +++ b/types/amap-js-api/lngLat.d.ts @@ -1,11 +1,39 @@ declare namespace AMap { class LngLat { + /** + * 构造一个地理坐标对象 + * @param lng 经度 + * @param lat 纬度 + * @param noAutofix 是否自动修正 + */ constructor(lng: number, lat: number, noAutofix?: boolean); + /** + * 移动当前经纬度坐标得到新的坐标 + * @param east 移动经度,向右为正值 + * @param north 移动维度,向上为正值 + */ offset(east: number, north: number): LngLat; + /** + * 当前经纬度和传入经纬度或者经纬度数组连线之间的地面距离,单位为米 + * @param lnglat 对比目标 + */ distance(lnglat: LngLat | LngLat[]): number; + /** + * 获取经度值 + */ getLng(): number; + /** + * 获取纬度值 + */ getLat(): number; + /** + * 判断当前坐标对象与传入坐标对象是否相等 + * @param lnglat 判断目标 + */ equals(lnglat: LngLat): boolean; + /** + * 以字符串的形式返回 + */ toString(): string; // internal diff --git a/types/amap-js-api/map.d.ts b/types/amap-js-api/map.d.ts index 46edc68577..e7937966b1 100644 --- a/types/amap-js-api/map.d.ts +++ b/types/amap-js-api/map.d.ts @@ -3,39 +3,145 @@ declare namespace AMap { type Feature = 'bg' | 'point' | 'road' | 'building'; type ViewMode = '2D' | '3D'; interface Options { + /** + * 地图视口,用于控制影响地图静态显示的属性 + */ view?: View2D; + /** + * 地图图层数组,数组可以是图层 中的一个或多个,默认为普通二维地图 + */ layers?: Layer[]; + /** + * 地图显示的缩放级别 + */ zoom?: number; + /** + * 地图中心点坐标值 + */ center?: LocationValue; + /** + * 地图标注显示顺序 + */ labelzIndex?: number; + /** + * 地图显示的缩放级别范围 + */ zooms?: [number, number]; + /** + * 地图语言类型 + */ lang?: Lang; + /** + * 地图默认鼠标样式 + */ defaultCursor?: string; + /** + * 地图显示的参考坐标系 + */ crs?: 'EPSG3857' | 'EPSG3395' | 'EPSG4326'; + /** + * 地图平移过程中是否使用动画 + */ animateEnable?: boolean; + /** + * 是否开启地图热点和标注的hover效果 + */ isHotspot?: boolean; + /** + * 当前地图中默认显示的图层 + */ defaultLayer?: TileLayer; + /** + * 地图是否可旋转 + */ rotateEnable?: boolean; + /** + * 是否监控地图容器尺寸变化 + */ resizeEnable?: boolean; + /** + * 是否在有矢量底图的时候自动展示室内地图 + */ showIndoorMap?: boolean; + /** + * 在展示矢量图的时候自动展示室内地图图层 + */ + // indoorMap?: IndorMap + /** + * 是否支持可以扩展最大缩放级别 + */ expandZoomRange?: boolean; + /** + * 地图是否可通过鼠标拖拽平移 + */ dragEnable?: boolean; + /** + * 地图是否可缩放 + */ zoomEnable?: boolean; + /** + * 地图是否可通过双击鼠标放大地图 + */ doubleClickZoom?: boolean; + /** + * 地图是否可通过键盘控制 + */ keyboardEnable?: boolean; + /** + * 地图是否使用缓动效果 + */ jogEnable?: boolean; + /** + * 地图是否可通过鼠标滚轮缩放浏览 + */ scrollWheel?: boolean; + /** + * 地图在移动终端上是否可通过多点触控缩放浏览地图 + */ touchZoom?: boolean; + /** + * 当touchZoomCenter=1的时候,手机端双指缩放的以地图中心为中心,否则默认以双指中间点为中心 + */ touchZoomCenter?: number; + /** + * 设置地图的显示样式 + */ mapStyle?: string; + /** + * 设置地图上显示的元素种类 + */ features?: Feature[] | 'all' | Feature; + /** + * 设置地图显示3D楼块效果 + */ showBuildingBlock?: boolean; + /** + * 视图模式 + */ viewMode?: ViewMode; + /** + * 俯仰角度 + */ pitch?: number; + /** + * 是否允许设置俯仰角度 + */ pitchEnable?: boolean; + /** + * 楼块出现和消失的时候是否显示动画过程 + */ buildingAnimation?: boolean; + /** + * 调整天空颜色 + */ skyColor?: string; + /** + * 设置地图的预加载模式 + */ preloadMode?: boolean; + /** + * 为 Map 实例指定掩模的路径,各图层将只显示路径范围内图像 + */ mask?: Array<[number, number]> | Array> | Array>>; maxPitch?: number; rotation?: number; @@ -58,24 +164,67 @@ declare namespace AMap { // detectRetina: number; } interface Status { + /** + * 是否开启动画 + */ animateEnable: boolean; + /** + * 是否双击缩放 + */ doubleClickZoom: boolean; + /** + * 是否支持拖拽 + */ dragEnable: boolean; isHotspot: boolean; + /** + * 是否开启缓动效果 + */ jogEnable: boolean; + /** + * 是否支持键盘 + */ keyboardEnable: boolean; + /** + * 是否支持调整俯仰角 + */ pitchEnable: boolean; resizeEnable: boolean; + /** + * 是否支持旋转 + */ rotateEnable: boolean; + /** + * 是否支持滚轮缩放 + */ scrollWheel: boolean; + /** + * 是否支持触摸缩放 + */ touchZoom: boolean; + /** + * 是否支持缩放 + */ zoomEnable: boolean; } type HotspotEvent = Event; interface EventMap { @@ -113,73 +262,305 @@ declare namespace AMap { } class Map extends EventEmitter { + /** + * 构造一个地图对象 + * @param container 地图容器的id或者是DOM元素 + * @param opts 选项 + */ constructor(container: string | HTMLElement, opts?: Map.Options); + /** + * 唤起高德地图客户端marker页 + * @param obj 唤起参数 + */ poiOnAMAP(obj: { id: string; location?: LocationValue; name?: string }): void; + /** + * 唤起高德地图客户端marker详情页 + * @param obj 唤起参数 + */ detailOnAMAP(obj: { id: string; location?: LocationValue; name?: string }): void; + /** + * 获取当前地图缩放级别 + */ getZoom(): number; + /** + * 获取地图图层数组 + */ getLayers(): Layer[]; + /** + * 获取地图中心点经纬度坐标值 + */ getCenter(): LngLat; + /** + * 返回地图对象的容器 + */ getContainer(): HTMLElement | null; + /** + * 获取地图中心点所在区域 + */ getCity(callback: (cityData: { + /** + * 市名称 + */ city: string; + /** + * 市代码 + */ citycode: string; + /** + * 区名称 + */ district: string; + /** + * 省 + */ province: string | never[]; // province is empty array when getCity fail }) => void): void; + /** + * 获取当前地图视图范围,获取当前可视区域 + */ getBounds(): Bounds; + /** + * 获取当前地图标注的显示顺序 + */ getLabelzIndex(): number; + /** + * 获取Map的限制区域 + */ getLimitBounds(): Bounds; + /** + * 获取地图语言类型 + */ getLang(): Lang; + /** + * 获取地图容器像素大小 + */ getSize(): Size; + /** + * 获取地图顺时针旋转角度 + */ getRotation(): number; + /** + * 获取当前地图状态信息 + */ getStatus(): Map.Status; + /** + * 获取地图默认鼠标指针样式 + */ getDefaultCursor(): string; + /** + * 获取指定位置的地图分辨率 + * @param point 指定经纬度 + */ getResolution(point?: LocationValue): number; + /** + * 获取当前地图比例尺 + * @param dpi dpi + */ getScale(dpi?: number): number; + /** + * 设置地图显示的缩放级别 + * @param level 缩放级别 + */ setZoom(level: number): void; + /** + * 设置地图标注显示的顺序 + * @param index 显示顺序 + */ setLabelzIndex(index: number): void; + /** + * 设置地图图层数组 + * @param layers 图层数组 + */ setLayers(layers: Layer[]): void; + /** + * 添加覆盖物/图层 + * @param overlay 覆盖物/图层 + */ add(overlay: Overlay | Overlay[]): void; + /** + * 删除覆盖物/图层 + * @param overlay 覆盖物/图层 + */ remove(overlay: Overlay | Overlay[]): void; + /** + * 返回添加的覆盖物对象 + * @param type 覆盖物类型 + */ getAllOverlays(type?: 'marker' | 'circle' | 'polyline' | 'polygon'): Overlay[]; + /** + * 设置地图显示的中心点 + * @param center 中心点经纬度 + */ setCenter(center: LocationValue): void; + /** + * 地图缩放至指定级别并以指定点为地图显示中心点 + * @param zoomLevel 缩放等级 + * @param center 缩放中心 + */ setZoomAndCenter(zoomLevel: number, center: LocationValue): void; + /** + * 按照行政区名称或adcode来设置地图显示的中心点。 + * @param city 城市名称或城市编码 + * @param callback 回调 + */ setCity(city: string, callback: (this: this, coord: [string, string], zoom: number) => void): void; + /** + * 指定当前地图显示范围 + * @param bound 显示范围 + */ setBounds(bound: Bounds): Bounds; + /** + * 设置Map的限制区域 + * @param bound 限制区域 + */ setLimitBounds(bound: Bounds): void; + /** + * 清除限制区域 + */ clearLimitBounds(): void; + /** + * 设置地图语言类型 + * @param lang 语言类型 + */ setLang(lang: Lang): void; + /** + * 设置地图顺时针旋转角度,旋转原点为地图容器中心点 + * @param rotation 旋转角度 + */ setRotation(rotation: number): void; + /** + * 设置当前地图显示状态 + * @param status 状态 + */ setStatus(status: Partial): void; + /** + * 设置鼠标指针默认样式 + * @param cursor 指针样式 + */ setDefaultCursor(cursor: string): void; + /** + * 地图放大一级显示 + */ zoomIn(): void; + /** + * 地图缩小一级显示 + */ zoomOut(): void; + /** + * 地图中心点平移至指定点位置 + * @param position 目标位置经纬度 + */ panTo(position: LocationValue): void; + /** + * 以像素为单位,沿x方向和y方向移动地图 + * @param x 横向移动像素,向右为正 + * @param y 纵向移动像素,向下为正 + */ panBy(x: number, y: number): void; + /** + * 根据地图上添加的覆盖物分布情况,自动缩放地图到合适的视野级别 + * @param overlayList 覆盖物数组 + * @param immediately 是否需要动画过程 + * @param avoid 上下左右的像素避让宽度 + * @param maxZoom 最大缩放级别 + */ setFitView( overlayList?: Overlay | Overlay[], immediately?: boolean, avoid?: [number, number, number, number], maxZoom?: number ): Bounds | false | undefined; + /** + * 删除地图上所有的覆盖物 + */ clearMap(): void; + /** + * 注销地图对象,并清空地图容器 + */ destroy(): void; + /** + * 加载插件, + * tips: 插件的类型定义不在本类型定义中给出,需要另行安装例如 + * 3d地图:@types/amap-js-api-map3d + * 地区搜索:@types/amap-js-api-place-search + * @param name 插件名称 + * @param callback 插件加载完成后的回调函数 + */ plugin(name: string | string[], callback: () => void): this; + /** + * 添加控件 + * @param control 控件 + */ addControl(control: {}): void; // TODO + /** + * 移除控件 + * @param control 控件 + */ removeControl(control: {}): void; // TODO + /** + * 清除地图上的信息窗体。 + */ clearInfoWindow(): void; + /** + * 平面地图像素坐标转换为地图经纬度坐标 + * @param pixel 像素坐标 + * @param level 缩放等级 + */ pixelToLngLat(pixel: Pixel, level?: number): LngLat; + /** + * 地图经纬度坐标转换为平面地图像素坐标 + * @param lnglat 经纬度坐标 + * @param level 缩放等级 + */ lnglatToPixel(lnglat: LocationValue, level?: number): Pixel; + /** + * 地图容器像素坐标转为地图经纬度坐标 + * @param pixel 地图像素坐标 + */ containerToLngLat(pixel: Pixel): LngLat; + /** + * 地图经纬度坐标转为地图容器像素坐标 + * @param lnglat 经纬度坐标 + */ lngLatToContainer(lnglat: LocationValue): Pixel; + /** + * 地图经纬度坐标转为地图容器像素坐标 + * @param lnglat 经纬度坐标 + */ lnglatTocontainer(lnglat: LocationValue): Pixel; + /** + * 设置地图的显示样式 + * @param style 地图样式 + */ setMapStyle(style: string): void; + /** + * 获取地图显示样式 + */ getMapStyle(): string; + /** + * 设置地图上显示的元素种类 + * @param feature 元素 + */ setFeatures(feature: Map.Feature | Map.Feature[] | 'all'): void; + /** + * 获取地图显示元素种类 + */ getFeatures(): Map.Feature | Map.Feature[] | 'all'; + /** + * 修改底图图层 + * @param layer 图层 + */ setDefaultLayer(layer: TileLayer): void; + /** + * 设置俯仰角 + * @param pitch 俯仰角 + */ setPitch(pitch: number): void; + /** + * 获取俯仰角 + */ getPitch(): number; + getViewMode_(): Map.ViewMode; lngLatToGeodeticCoord(lnglat: LocationValue): Pixel; geodeticCoordToLngLat(pixel: Pixel): LngLat; diff --git a/types/amap-js-api/overlay/bezierCurve.d.ts b/types/amap-js-api/overlay/bezierCurve.d.ts index 5778cb72a6..b861440a92 100644 --- a/types/amap-js-api/overlay/bezierCurve.d.ts +++ b/types/amap-js-api/overlay/bezierCurve.d.ts @@ -2,18 +2,31 @@ declare namespace AMap { namespace BezierCurve { interface EventMap extends Polyline.EventMap { } type Options = Merge, { - // internal + /** + * 贝瑟尔曲线的路径 + */ path: Array>>; + // internal tolerance?: number; interpolateNumLimit?: [number | number]; }>; interface GetOptionsResult extends Polyline.GetOptionsResult { + /** + * 贝瑟尔曲线的路径 + */ path: Array; } } class BezierCurve extends Polyline { + /** + * 贝瑟尔曲线 + * @param options 覆盖物选项 + */ constructor(options: BezierCurve.Options); + /** + * 获取覆盖物选项 + */ getOptions(): Partial>; // internal getInterpolateLngLats(): LngLat[]; diff --git a/types/amap-js-api/overlay/circle.d.ts b/types/amap-js-api/overlay/circle.d.ts index 2a1cbd9020..c718119e5a 100644 --- a/types/amap-js-api/overlay/circle.d.ts +++ b/types/amap-js-api/overlay/circle.d.ts @@ -34,15 +34,50 @@ declare namespace AMap { } class Circle extends ShapeOverlay { + /** + * 圆形覆盖物 + * @param options 覆盖物选项 + */ constructor(options?: Circle.Options); + /** + * 设置圆中心点 + * @param center 中心点经纬度 + * @param preventEvent 阻止触发事件 + */ setCenter(center: LocationValue, preventEvent?: boolean): void; + /** + * 获取圆中心点 + */ getCenter(): LngLat | undefined; + /** + * 获取圆外切矩形范围 + */ getBounds(): Bounds | null; + /** + * 设置圆形的半径 + * @param radius 半径 + * @param preventEvent 阻止触发事件 + */ setRadius(radius: number, preventEvent?: boolean): void; + /** + * 获取圆形的半径 + */ getRadius(): number; + /** + * 修改选项 + * @param options 选项 + */ setOptions(options?: Circle.Options): void; + /** + * 获取选项 + */ getOptions(): Partial>; + /** + * 判断指定点坐标是否在圆内 + * @param point 坐标 + */ contains(point: LocationValue): boolean; + // internal getPath(count?: number): LngLat[]; } diff --git a/types/amap-js-api/overlay/circleMarker.d.ts b/types/amap-js-api/overlay/circleMarker.d.ts index 13e4162f46..0b67d7f13e 100644 --- a/types/amap-js-api/overlay/circleMarker.d.ts +++ b/types/amap-js-api/overlay/circleMarker.d.ts @@ -1,4 +1,7 @@ declare namespace AMap { // tslint:disable-next-line; + /** + * 圆点标记 + */ class CircleMarker extends Circle {} } diff --git a/types/amap-js-api/overlay/contextMenu.d.ts b/types/amap-js-api/overlay/contextMenu.d.ts index 72c7fc2852..eacb6673c8 100644 --- a/types/amap-js-api/overlay/contextMenu.d.ts +++ b/types/amap-js-api/overlay/contextMenu.d.ts @@ -1,7 +1,11 @@ declare namespace AMap { namespace ContextMenu { interface Options { + /** + * 右键菜单内容 + */ content?: string | HTMLElement; + // internal visible?: boolean; } @@ -14,10 +18,33 @@ declare namespace AMap { } class ContextMenu extends Overlay { + /** + * 地图右键菜单 + * @param options 选项 + */ constructor(options?: ContextMenu.Options); + /** + * 右键菜单中添加菜单项 + * @param text 菜单显示内容 + * @param fn 该菜单下需进行的操作 + * @param num 当前菜单项在右键菜单中的排序位置,以0开始 + */ addItem(text: string, fn: (this: HTMLLIElement) => void, num?: number): void; - removeItem(test: string, fn: (this: HTMLLIElement) => void): void; + /** + * 删除一个菜单项 + * @param text 菜单显示内容 + * @param fn 该菜单下需进行的操作 + */ + removeItem(text: string, fn: (this: HTMLLIElement) => void): void; + /** + * 在地图的指定位置打开右键菜单。 + * @param map 目标地图 + * @param position 打开位置经纬度 + */ open(map: Map, position: LocationValue): void; + /** + * 关闭右键菜单 + */ close(): void; } } diff --git a/types/amap-js-api/overlay/ellipse.d.ts b/types/amap-js-api/overlay/ellipse.d.ts index 55feaf3112..de9da22e0c 100644 --- a/types/amap-js-api/overlay/ellipse.d.ts +++ b/types/amap-js-api/overlay/ellipse.d.ts @@ -6,7 +6,13 @@ declare namespace AMap { } interface Options extends Polygon.Options { + /** + * 椭圆的中心 + */ center?: LocationValue; + /** + * 椭圆半径 + */ radius?: [number, number]; } type GetOptionsResult = Merge, { @@ -15,9 +21,25 @@ declare namespace AMap { } class Ellipse extends Polygon { + /** + * 椭圆 + * @param options 选项 + */ constructor(options?: Ellipse.Options); + /** + * 获取椭圆的中心点 + */ getCenter(): LngLat | undefined; + /** + * 设置椭圆的中心点 + * @param center 中心点 + * @param preventEvent 阻止触发事件 + */ setCenter(center: LocationValue, preventEvent?: boolean): void; + /** + * 修改椭圆属性 + * @param options 属性 + */ setOptions(options: Ellipse.Options): void; // internal diff --git a/types/amap-js-api/overlay/geoJSON.d.ts b/types/amap-js-api/overlay/geoJSON.d.ts index 75098a59f0..aa3554cb04 100644 --- a/types/amap-js-api/overlay/geoJSON.d.ts +++ b/types/amap-js-api/overlay/geoJSON.d.ts @@ -24,9 +24,27 @@ declare namespace AMap { features: GeoJSONObject[]; }; interface Options { + /** + * 要加载的标准GeoJSON对象 + */ geoJSON?: GeoJSONObject | GeoJSONObject[]; + /** + * 指定点要素的绘制方式 + * @param obj GeoJSON对象 + * @param lnglat 点的位置 + */ getMarker?(obj: GeoJSONObject, lnglat: LngLat): Marker; + /** + * 指定线要素的绘制方式 + * @param obj GeoJSON对象 + * @param lnglats 线的路径 + */ getPolyline?(obj: GeoJSONObject, lnglats: LngLat[]): Polyline; + /** + * 指定面要素的绘制方式 + * @param obj GeoJSON对象 + * @param lnglats 面的路径 + */ getPolygon?(obj: GeoJSONObject, lnglats: LngLat[]): Polygon; coordsToLatLng?(lnglat: LngLat): LngLat; @@ -36,8 +54,19 @@ declare namespace AMap { } class GeoJSON extends OverlayGroup { + /** + * GeoJSON + * @param options 选项 + */ constructor(options?: GeoJSON.Options); + /** + * 加载新的GeoJSON对象,转化为覆盖物,旧的覆盖物将移除 + * @param obj GeoJSON对象 + */ importData(obj: GeoJSON.GeoJSONObject | GeoJSON.GeoJSONObject[]): void; + /** + * 将当前对象包含的覆盖物转换为GeoJSON对象 + */ toGeoJSON(): GeoJSON.GeoJSONObject[]; } } diff --git a/types/amap-js-api/overlay/icon.d.ts b/types/amap-js-api/overlay/icon.d.ts index be300feef3..18d75921bf 100644 --- a/types/amap-js-api/overlay/icon.d.ts +++ b/types/amap-js-api/overlay/icon.d.ts @@ -1,16 +1,39 @@ declare namespace AMap { namespace Icon { interface Options { + /** + * 图标尺寸 + */ size?: SizeValue; + /** + * 图标取图偏移量 + */ imageOffset?: Pixel; + /** + * 图标的取图地址 + */ image?: string; + /** + * 图标所用图片大小 + */ imageSize?: SizeValue; } } class Icon extends EventEmitter { + /** + * 点标记的图标 + * @param options 选项 + */ constructor(options?: Icon.Options); + /** + * 设置图标图片大小 + * @param size 大小 + */ setImageSize(size: SizeValue): void; + /** + * 获取图标图片大小 + */ getImageSize(): Size; } } diff --git a/types/amap-js-api/overlay/infoWindow.d.ts b/types/amap-js-api/overlay/infoWindow.d.ts index 54bedd95a8..1c9b69a9a3 100644 --- a/types/amap-js-api/overlay/infoWindow.d.ts +++ b/types/amap-js-api/overlay/infoWindow.d.ts @@ -7,13 +7,37 @@ declare namespace AMap { } interface Options extends Overlay.Options { + /** + * 是否自定义窗体 + */ isCustom?: boolean; + /** + * 是否自动调整窗体到视野内 + */ autoMove?: boolean; + /** + * 控制是否在鼠标点击地图后关闭信息窗体 + */ closeWhenClickMap?: boolean; + /** + * 显示内容 + */ content?: string | HTMLElement; + /** + * 信息窗体尺寸 + */ size?: SizeValue; + /** + * 信息窗体显示位置偏移量 + */ offset?: Pixel; + /** + * 信息窗体显示基点位置 + */ position?: LocationValue; + /** + * 是否显示信息窗体阴影 + */ showShadow?: boolean; // internal height?: number; @@ -21,16 +45,53 @@ declare namespace AMap { } class InfoWindow extends Overlay { + /** + * 信息展示窗体 + * @param options 选项 + */ constructor(options?: InfoWindow.Options); + /** + * 在地图的指定位置打开信息窗体 + * @param map 地图 + * @param position 打开的位置 + */ open(map: Map, position?: LocationValue): void; + /** + * 关闭信息窗体 + */ close(): void; + /** + * 获取信息窗体是否打开 + */ getIsOpen(): boolean; + /** + * 设置信息窗体内容 + * @param content 窗体内容 + */ setContent(content: string | HTMLElement): void; + /** + * 获取信息窗体内容 + */ getContent(): string | HTMLElement | undefined; + /** + * 设置信息窗体显示基点位置 + * @param lnglat 位置经纬度 + */ setPosition(lnglat: LocationValue): void; + /** + * 获取信息窗体显示基点位置 + */ getPosition(): LngLat | undefined; + /** + * 设置信息窗体大小 + * @param size 大小 + */ setSize(size: SizeValue): void; + /** + * 获取信息窗体大小 + */ getSize(): Size | undefined; + // internal setOffset(offset: Pixel): void; } diff --git a/types/amap-js-api/overlay/marker.d.ts b/types/amap-js-api/overlay/marker.d.ts index e24ce7be8f..42dddf394a 100644 --- a/types/amap-js-api/overlay/marker.d.ts +++ b/types/amap-js-api/overlay/marker.d.ts @@ -26,78 +26,268 @@ declare namespace AMap { } interface Options extends Overlay.Options { + /** + * 点标记在地图上显示的位置 + */ position?: LocationValue; + /** + * 点标记显示位置偏移量 + */ offset?: Pixel; + /** + * 需在点标记中显示的图标 + */ icon?: string | Icon; + /** + * 点标记显示内容 + */ content?: string | HTMLElement; + /** + * 鼠标点击时marker是否置顶 + */ topWhenClick?: boolean; + /** + * 是否将覆盖物的鼠标或touch等事件冒泡到地图上 + */ bubble?: boolean; + /** + * 点标记是否可拖拽移动 + */ draggable?: boolean; + /** + * 拖拽点标记时是否开启点标记离开地图的效果 + */ raiseOnDrag?: boolean; + /** + * 鼠标悬停时的鼠标样式 + */ cursor?: string; + /** + * 点标记是否可见 + */ visible?: boolean; + /** + * 点标记的叠加顺序 + */ zIndex?: number; + /** + * 点标记的旋转角度 + */ angle?: number; + /** + * 是否自动旋转 + */ autoRotation?: boolean; + /** + * 点标记的动画效果 + */ animation?: AnimationName; + /** + * 点标记阴影 + */ shadow?: Icon | string; + /** + * 鼠标滑过点标记时的文字提示 + */ title?: string; + /** + * 可点击区域 + */ shape?: MarkerShape; + /** + * 文本标注 + */ label?: Label; - zooms?: [number, number]; // internal + zooms?: [number, number]; topWhenMouseOver?: boolean; height?: number; } } class Marker extends Overlay { + /** + * 点标记 + * @param options 选项 + */ constructor(options?: Marker.Options); + /** + * 唤起高德地图客户端标注页 + * @param obj 唤起参数 + */ markOnAMAP(obj?: { name?: string, position?: LocationValue }): void; + /** + * 获取偏移量 + */ getOffset(): Pixel; + /** + * 设置偏移量 + * @param offset 偏移量 + */ setOffset(offset: Pixel): void; + /** + * 设置点标记的动画效果 + * @param animate 动画效果类型 + */ setAnimation(animate: AnimationName, prevent?: boolean): void; + /** + * 获取点标记的动画效果类型 + */ getAnimation(): AnimationName; + /** + * 设置点标记是支持鼠标单击事件 + * @param cilckable 是否支持点击 + */ setClickable(cilckable: boolean): void; + /** + * 获取点标记是否支持鼠标单击事件 + */ getClickable(): boolean; + /** + * 获取点标记的位置 + */ getPosition(): LngLat | undefined; + /** + * 设置点标记位置 + * @param position 位置经纬度 + */ setPosition(position: LocationValue): void; + /** + * 设置点标记的旋转角度 + * @param angle 旋转角度 + */ setAngle(angle: number): void; + /** + * 设置点标记文本标签内容 + * @param label 标签内容 + */ setLabel(label?: Marker.Label): void; + /** + * 获取点标记文本标签内容 + */ getLabel(): Marker.Label | undefined; + /** + * 获取点标记的旋转角度 + */ getAngle(): number; + /** + * 设置点标记的叠加顺序 + * @param index 层级 + */ setzIndex(index: number): void; + /** + * 获取点标记的叠加顺序 + */ getzIndex(): number; + /** + * 设置点标记的显示图标 + * @param content 图标 + */ setIcon(content: string | Icon): void; + /** + * 获取Icon内容 + */ getIcon(): string | Icon | undefined; + /** + * 设置点标记对象是否可拖拽移动 + * @param draggable 是否可拖拽移动 + */ setDraggable(draggable: boolean): void; + /** + * 获取点标记对象是否可拖拽移动 + */ getDraggable(): boolean; + /** + * 设置鼠标悬停时的光标 + * @param cursor 光标 + */ setCursor(cursor: string): void; + /** + * 设置点标记显示内容,可以是HTML要素字符串或者HTML DOM对象 + * @param content 显示内容 + */ setContent(content: string | HTMLElement): void; + /** + * 获取点标记内容 + */ getContent(): string | HTMLElement; + /** + * 以指定的速度,点标记沿指定的路径移动 + * @param path 移动轨迹 + * @param speed 速度 + * @param timingFunction 缓动函数 + * @param circleable 是否循环 + */ moveAlong( path: LngLat[], speed: number, timingFunction?: (t: number) => number, circleable?: boolean ): void; + /** + * 以给定速度移动点标记到指定位置 + * @param lnglat 目标位置 + * @param speed 速度 + * @param timingFunction 缓动函数 + */ moveTo( - path: LocationValue, + lnglat: LocationValue, speed: number, timingFunction?: (t: number) => number ): void; + /** + * 点标记停止动画 + */ stopMove(): void; + /** + * 暂定点标记的动画效果 + */ pauseMove(): boolean; + /** + * 重新开始点标记的动画效果 + */ resumeMove(): boolean; + /** + * 指定目标显示地图 + * @param map 地图 + */ setMap(map: null | Map): void; + /** + * 鼠标滑过点标时的文字提示 + * @param title 提示文字 + */ setTitle(title: string): void; + /** + * 获取点标记的文字提示 + */ getTitle(): string | undefined; + /** + * 设置是否展示在最顶层 + * @param isTop 是否展示在最顶层 + */ setTop(isTop: boolean): void; + /** + * 获取是否展示在最顶层 + */ getTop(): boolean; + /** + * 设置阴影效果 + * @param icon 阴影效果 + */ setShadow(icon?: Icon | string): void; + /** + * 获取阴影图标 + */ getShadow(): Icon | undefined | string; + /** + * 设置可点击区域 + * @param shape 可点击区域 + */ setShape(shape?: MarkerShape): void; + /** + * 获取可点击区域 + */ getShape(): MarkerShape | undefined; } } diff --git a/types/amap-js-api/overlay/markerShape.d.ts b/types/amap-js-api/overlay/markerShape.d.ts index f0d6c39bac..19264f26cf 100644 --- a/types/amap-js-api/overlay/markerShape.d.ts +++ b/types/amap-js-api/overlay/markerShape.d.ts @@ -16,6 +16,10 @@ declare namespace AMap { } class MarkerShape extends EventEmitter { + /** + * Marker点击范围 + * @param options 选项 + */ constructor(options: MarkerShape.Options); } } diff --git a/types/amap-js-api/overlay/overlay.d.ts b/types/amap-js-api/overlay/overlay.d.ts index 1726b39c3e..f90bdb57ed 100644 --- a/types/amap-js-api/overlay/overlay.d.ts +++ b/types/amap-js-api/overlay/overlay.d.ts @@ -13,21 +13,59 @@ declare namespace AMap { mouseup: MapsEvent<'mouseup', I>; } interface Options { + /** + * 所属地图 + */ map?: Map; + /** + * 鼠标悬停时的鼠标样式 + */ cursor?: string; + /** + * 自定义数据 + */ extData?: ExtraData; + /** + * 事件是否穿透到地图 + */ bubble?: boolean; + /** + * 是否支持点击 + */ clickable?: boolean; + /** + * 是否支持拖拽 + */ draggable?: boolean; } } abstract class Overlay extends EventEmitter { constructor(options?: Overlay.Options); + /** + * 显示覆盖物 + */ show(): void; + /** + * 隐藏覆盖物 + */ hide(): void; + /** + * 获取所属地图 + */ getMap(): Map | null | undefined; + /** + * 设置所属地图 + * @param map 地图 + */ setMap(map: Map | null): void; + /** + * 设置自定义数据 + * @param extData 自定义数据 + */ setExtData(extData: ExtraData): void; + /** + * 获取自定义数据 + */ getExtData(): ExtraData | {}; // internal diff --git a/types/amap-js-api/overlay/overlayGroup.d.ts b/types/amap-js-api/overlay/overlayGroup.d.ts index d397505b04..a219e38fcd 100644 --- a/types/amap-js-api/overlay/overlayGroup.d.ts +++ b/types/amap-js-api/overlay/overlayGroup.d.ts @@ -11,20 +11,72 @@ type ReferOverlayOptions = declare namespace AMap { class OverlayGroup extends Overlay { + /** + * 覆盖物集合 + * @param overlays 覆盖物 + */ constructor(overlays?: O | O[]); + /** + * 添加单个覆盖物到集合中,不支持添加重复的覆盖物 + * @param overlay 覆盖物 + */ addOverlay(overlay: O | O[]): this; + /** + * 添加覆盖物数组到集合中,不支持添加重复的覆盖物 + * @param overlay 覆盖物数组 + */ addOverlays(overlay: O | O[]): this; + /** + * 返回当前集合中所有的覆盖物 + */ getOverlays(): O[]; + /** + * 判断传入的覆盖物实例是否在集合中 + * @param overlay 覆盖物 + */ hasOverlay(overlay: O | ((this: null, item: O, index: number, list: O[]) => boolean)): boolean; + /** + * 从集合中删除传入的覆盖物实例 + * @param overlay 覆盖物 + */ removeOverlay(overlay: O | O[]): this; + /** + * 从集合中删除传入的覆盖物实例数组 + * @param overlay 覆盖物数组 + */ removeOverlays(overlay: O | O[]): this; + /** + * 清空集合 + */ clearOverlays(): this; + /** + * 对集合中的覆盖物做迭代操作 + * @param iterator 迭代回调 + * @param context 执行上下文 + */ eachOverlay(iterator: (this: C, overlay: O, index: number, overlays: O[]) => void, context?: C): this; + /** + * 指定集合中里覆盖物的显示地图 + * @param map 地图 + */ setMap(map: null | Map): this; + /** + * 修改覆盖物属性 + * @param options 属性 + */ setOptions(options: ReferOverlayOptions): this; + /** + * 在地图上显示集合中覆盖物 + */ show(): this; + /** + * 在地图上隐藏集合中覆盖物 + */ hide(): this; - + /** + * 查找集合中的覆盖物 + * @param finder 查找回调 + */ getOverlay(finder: ((this: null, item: O, index: number, list: O[]) => boolean) | O): O | null; } } diff --git a/types/amap-js-api/overlay/pathOverlay.d.ts b/types/amap-js-api/overlay/pathOverlay.d.ts index de21aa35a7..d46b23a1c3 100644 --- a/types/amap-js-api/overlay/pathOverlay.d.ts +++ b/types/amap-js-api/overlay/pathOverlay.d.ts @@ -2,19 +2,49 @@ declare namespace AMap { namespace PathOverlay { interface EventMap extends ShapeOverlay.EventMap { } interface Options extends Overlay.Options { + /** + * 是否可见 + */ visible?: boolean; + /** + * 覆盖物层级 + */ zIndex?: number; + /** + * 描边线条颜色 + */ strokeColor?: string; + /** + * 描边线条透明度 + */ strokeOpacity?: number; + /** + * 描边宽度 + */ strokeWeight?: number; + /** + * 描边样式 + */ strokeStyle?: StrokeStyle; + /** + * 虚线间隔 + */ strokeDasharray?: number[]; + /** + * 折线拐点的绘制样式 + */ lineJoin?: StrokeLineJoin; + /** + * 折线两端线帽的绘制样式 + */ lineCap?: StrokeLineCap; } } abstract class PathOverlay extends ShapeOverlay { constructor(options?: PathOverlay.Options); + /** + * 获取范围 + */ getBounds(): Bounds | (this extends Rectangle ? undefined : null); } } diff --git a/types/amap-js-api/overlay/polygon.d.ts b/types/amap-js-api/overlay/polygon.d.ts index 8792e0e135..20a9c3595e 100644 --- a/types/amap-js-api/overlay/polygon.d.ts +++ b/types/amap-js-api/overlay/polygon.d.ts @@ -2,31 +2,77 @@ declare namespace AMap { namespace Polygon { interface EventMap extends PathOverlay.EventMap { } interface Options extends PathOverlay.Options { + /** + * 多边形轮廓线的节点坐标数组 + */ path?: LocationValue[] | LocationValue[][]; + /** + * 多边形填充颜色 + */ fillColor?: string; + /** + * 边形填充透明度 + */ fillOpacity?: number; } interface GetOptionsResult extends ShapeOverlay.GetOptionsResult { + /** + * 多边形填充颜色 + */ fillColor: string; + /** + * 边形填充透明度 + */ fillOpacity: number; + /** + * 多边形轮廓线的节点坐标数组 + */ path: LngLat[] | LngLat[][]; + /** + * 折线拐点的绘制样式 + */ lineJoin: StrokeLineJoin; texture: string; } } class Polygon extends PathOverlay { + /** + * 多边形 + * @param options 选项 + */ constructor(options?: Polygon.Options); + /** + * 设置多边形轮廓线节点数组 + * @param path 轮廓线节点 + */ setPath(path: LocationValue[] | LocationValue[][]): void; + /** + * 获取多边形轮廓线节点数组 + */ getPath(): LngLat[] | LngLat[][]; + /** + * 修改多边形属性 + * @param options 属性 + */ setOptions(options: Polygon.Options): void; + /** + * 获取多边形的属性 + */ getOptions(): Partial< this extends Omit ? Ellipse.GetOptionsResult : this extends Omit ? Rectangle.GetOptionsResult : Polygon.GetOptionsResult >; + /** + * 获取多边形的面积 + */ getArea(): number; + /** + * 判断指定点坐标是否在多边形范围内 + * @param point 坐标 + */ contains(point: LocationValue): boolean; } } diff --git a/types/amap-js-api/overlay/polyline.d.ts b/types/amap-js-api/overlay/polyline.d.ts index 207279b208..c7abfa6331 100644 --- a/types/amap-js-api/overlay/polyline.d.ts +++ b/types/amap-js-api/overlay/polyline.d.ts @@ -2,45 +2,118 @@ declare namespace AMap { namespace Polyline { interface EventMap extends PathOverlay.EventMap { } interface GetOptionsResult extends ShapeOverlay.GetOptionsResult { + /** + * 线条是否带描边 + */ isOutline: boolean; + /** + * 线条描边颜色 + */ outlineColor: string; + /** + * 是否绘制成大地线 + */ geodesic: boolean; + /** + * 折线的节点数组 + */ path: LngLat[]; + /** + * 折线拐点的绘制样式 + */ lineJoin: StrokeLineJoin; + /** + * 折线两端线帽的绘制样式 + */ lineCap: StrokeLineCap; + /** + * 描边的宽度 + */ borderWeight: number; + /** + * 是否延路径显示方向箭头 + */ showDir: boolean; + /** + * 方向箭头颜色 + */ dirColor: string; + /** + * 方向箭头图片 + */ dirImg: string; } interface Options extends PathOverlay.Options { + /** + * 线条是否带描边 + */ isOutline?: boolean; + /** + * 线条描边颜色 + */ outlineColor?: string; + /** + * 是否绘制成大地线 + */ geodesic?: boolean; + /** + * 方向箭头颜色 + */ dirColor?: string; + /** + * 描边的宽度 + */ borderWeight?: number; + /** + * 是否延路径显示方向箭头 + */ showDir?: boolean; + // internal + /** + * 折线的节点数组 + */ path?: LocationValue[]; } } class Polyline extends PathOverlay { + /** + * 折线 + * @param options 选项 + */ constructor(options?: BezierCurve.Options | Polyline.Options); + /** + * 设置组成该折线的节点数组 + * @param path 节点数组 + */ setPath( path: this extends Omit ? Array>> : LocationValue[] ): void; + /** + * 获取折线路径的节点数组 + */ getPath(): this extends Omit ? Array : LngLat[]; + /** + * 获取折线的总长度(单位:米) + */ getLength(): number; + /** + * 设置线的属性 + * @param options 属性 + */ setOptions(options: this extends Omit ? Partial> : Polyline.Options ): void; + /** + * 获取线的属性 + */ getOptions(): Partial>; } } diff --git a/types/amap-js-api/overlay/rectangle.d.ts b/types/amap-js-api/overlay/rectangle.d.ts index 259e2072de..833a46d3dc 100644 --- a/types/amap-js-api/overlay/rectangle.d.ts +++ b/types/amap-js-api/overlay/rectangle.d.ts @@ -5,17 +5,39 @@ declare namespace AMap { } interface Options extends Polygon.Options { + /** + * 矩形的范围 + */ bounds?: Bounds; } type GetOptionsResult = Merge, { + /** + * 路径节点数组 + */ path: LngLat[]; + /** + * 矩形的范围 + */ bounds: Bounds; texture: string; }>; } class Rectangle extends Polygon { + /** + * 矩形 + * @param options 选项 + */ constructor(options?: Rectangle.Options); + /** + * 获取矩形范围 + * @param bounds 矩形的范围 + * @param preventEvent 阻止触发事件 + */ setBounds(bounds: Bounds, preventEvent?: boolean): void; + /** + * 修改矩形属性 + * @param options 属性 + */ setOptions(options: Partial): void; } } diff --git a/types/amap-js-api/overlay/shapeOverlay.d.ts b/types/amap-js-api/overlay/shapeOverlay.d.ts index b8f239aac1..ab07fa3d88 100644 --- a/types/amap-js-api/overlay/shapeOverlay.d.ts +++ b/types/amap-js-api/overlay/shapeOverlay.d.ts @@ -7,24 +7,74 @@ declare namespace AMap { change: Event<'change', { target: I }>; } interface GetOptionsResult { + /** + * 所属地图 + */ map: Map; + /** + * 层级 + */ zIndex: number; + /** + * 线条颜色 + */ strokeColor: string; + /** + * 线条透明度 + */ strokeOpacity: number; + /** + * 线条宽度 + */ strokeWeight: number; + /** + * 线条样式,虚线或者实线 + */ strokeStyle: StrokeStyle; + /** + * 虚线的分段 + */ strokeDasharray: number[]; + /** + * 自定义属性 + */ extData: ExtraData | {}; + /** + * 事件是否穿透到地图 + */ bubble: boolean; + /** + * 是否支持点击 + */ clickable: boolean; } } abstract class ShapeOverlay extends Overlay { + /** + * 设置覆盖物属性 + * @param options 属性 + */ abstract setOptions(options: {}): void; + /** + * 获得属性 + */ abstract getOptions(): {}; + /** + * 获得层级 + */ getzIndex(): number; + /** + * 设置层级 + * @param zIndex 层级 + */ setzIndex(zIndex: number): void; + /** + * 返回可见 + */ getVisible(): boolean; + /** + * 设置是否可以拖拽 + */ setDraggable(draggable: boolean): void; } } diff --git a/types/amap-js-api/overlay/text.d.ts b/types/amap-js-api/overlay/text.d.ts index db15ae08ce..50f9249ad9 100644 --- a/types/amap-js-api/overlay/text.d.ts +++ b/types/amap-js-api/overlay/text.d.ts @@ -4,16 +4,38 @@ declare namespace AMap { type VerticalAlign = 'top' | 'middle' | 'bottom'; interface EventMap extends Marker.EventMap { } interface Options extends Marker.Options { + /** + * 文本内容 + */ text?: string; + /** + * 对齐方式 + */ textAlign?: TextAlign; + verticalAlign?: VerticalAlign; } } class Text extends Marker { + /** + * 纯文本标记 + * @param options 选项 + */ constructor(options?: Text.Options); + /** + * 标记显示的文本内容 + */ getText(): string; + /** + * 修改文本内容 + * @param text 文本内容 + */ setText(text: string): void; + /** + * 设置文本样式 + * @param style 文本样式 + */ setStyle(style: object): void; } } diff --git a/types/amap-js-api/pixel.d.ts b/types/amap-js-api/pixel.d.ts index fab4605b7a..b211e1d88a 100644 --- a/types/amap-js-api/pixel.d.ts +++ b/types/amap-js-api/pixel.d.ts @@ -1,9 +1,28 @@ declare namespace AMap { class Pixel { + /** + * 像素坐标,确定地图上的一个像素点 + * @param x 横轴坐标 + * @param y 纵轴坐标 + * @param round 是否四舍五入 + */ constructor(x: number, y: number, round?: boolean); + /** + * 获得X方向像素坐标 + */ getX(): number; + /** + * 获得Y方向像素坐标 + */ getY(): number; + /** + * 当前像素坐标与传入像素坐标是否相等 + * @param point 目标像素坐标 + */ equals(point: Pixel): boolean; + /** + * 以字符串形式返回像素坐标对象 + */ toString(): string; // internal diff --git a/types/amap-js-api/size.d.ts b/types/amap-js-api/size.d.ts index 12a1e25423..f13c2fff0b 100644 --- a/types/amap-js-api/size.d.ts +++ b/types/amap-js-api/size.d.ts @@ -1,9 +1,24 @@ declare namespace AMap { class Size { + /** + * 地物对象的像素尺寸 + * @param width 宽度像素 + * @param height 长度像素 + */ constructor(width: number, height: number); + /** + * 获得宽度 + */ getWidth(): number; + /** + * 获得高度 + */ getHeight(): number; + /** + * 以字符串形式返回尺寸大小对象 + */ toString(): string; + // internal contains(size: { x: number; y: number }): boolean; } diff --git a/types/amap-js-api/util.d.ts b/types/amap-js-api/util.d.ts index 70b48c31d1..ee275d66b5 100644 --- a/types/amap-js-api/util.d.ts +++ b/types/amap-js-api/util.d.ts @@ -1,25 +1,64 @@ declare namespace AMap { namespace Util { + /** + * 将颜色名转换为16进制RGB颜色值 + * @param colorName 颜色名 + */ function colorNameToHex(colorName: string): string; - + /** + * 将16进制RGB转为rgba(R,G,B,A) + * @param hex 16进制RGB + */ function rgbHex2Rgba(hex: string): string; - + /** + * 将16进制RGBA转为rgba(R,G,B,A) + * @param hex 16进制RGBA + */ function argbHex2Rgba(hex: string): string; - + /** + * 判断一个对象是都为空 + * @param obj 目标对象 + */ function isEmpty(obj: object): boolean; - + /** + * 从数组删除元素 + * @param array 数组 + * @param item 元素 + */ function deleteItemFromArray(array: T[], item: T): T[]; - + /** + * 按索引删除数组元素 + * @param array 数组 + * @param index 索引 + */ function deleteItemFromArrayByIndex(array: T[], index: number): T[]; - + /** + * 返回元素索引 + * @param array 数组 + * @param item 元素 + */ function indexOf(array: T[], item: T): number; - + /** + * 保留小数点后指定位 + * @param floatNumber 数值 + * @param digits 小数点位数 + */ function format(floatNumber: number, digits?: number): number; - + /** + * 判断是否数组 + * @param data 判断对象 + */ function isArray(data: any): data is any[]; - + /** + * 判断参数是否为DOM元素 + * @param data 判断对象 + */ function isDOM(data: any): data is HTMLElement; - + /** + * 判断数组是否包含某个元素 + * @param array 数组 + * @param item 元素 + */ function includes(array: T[], item: T): boolean; function requestIdleCallback(callback: (...args: any[]) => any, options?: { timeout?: number }): number; diff --git a/types/amap-js-api/view2D.d.ts b/types/amap-js-api/view2D.d.ts index d662b4c50e..f246c5c67f 100644 --- a/types/amap-js-api/view2D.d.ts +++ b/types/amap-js-api/view2D.d.ts @@ -1,13 +1,29 @@ declare namespace AMap { namespace View2D { interface Options { + /** + * 地图中心点坐标值 + */ center?: LocationValue; + /** + * 地图顺时针旋转角度 + */ rotation?: number; + /** + * 地图显示的缩放级别 + */ zoom?: number; + /** + * 地图显示的参考坐标系 + */ crs?: 'EPGS3857' | 'EPGS3395' | 'EPGS4326'; } } class View2D extends EventEmitter { + /** + * 二维地图显示视口,用于定义二维地图静态显示属性 + * @param options 选项 + */ constructor(options?: View2D.Options); } }