1 | import { MapProps } from '@tarojs/components';
|
2 | import Taro from '../../index'
|
3 |
|
4 | declare module '../../index' {
|
5 | /** `MapContext` 实例,可通过 [Taro.createMapContext](./createMapContext) 获取。
|
6 | * `MapContext` 通过 id 跟一个 map 组件绑定,操作对应的 map 组件。
|
7 | * @supported weapp
|
8 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.html
|
9 | */
|
10 | interface MapContext {
|
11 | /** 获取当前地图中心的经纬度。返回的是 gcj02 坐标系,可以用于 [Taro.openLocation()](/docs/apis/location/openLocation)
|
12 | * @supported weapp
|
13 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.getCenterLocation.html
|
14 | */
|
15 | getCenterLocation(option?: MapContext.GetCenterLocationOption): Promise<MapContext.GetCenterLocationSuccessCallbackResult>
|
16 |
|
17 | /** 设置定位点图标,支持网络路径、本地路径、代码包路径
|
18 | * @supported weapp
|
19 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.setLocMarkerIcon.html
|
20 | */
|
21 | setLocMarkerIcon(option?: MapContext.SetLocMarkerIconOption): Promise<TaroGeneral.CallbackResult>
|
22 |
|
23 | /** 将地图中心移置当前定位点,此时需设置地图组件 show-location 为true。
|
24 | * @supported weapp
|
25 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.moveToLocation.html
|
26 | */
|
27 | moveToLocation(option: MapContext.MoveToLocationOption): Promise<TaroGeneral.CallbackResult>
|
28 |
|
29 | /** 平移marker,带动画
|
30 | * @supported weapp
|
31 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.translateMarker.html
|
32 | */
|
33 | translateMarker(option: MapContext.TranslateMarkerOption): Promise<TaroGeneral.CallbackResult>
|
34 |
|
35 | /** 沿指定路径移动 marker,用于轨迹回放等场景。动画完成时触发回调事件,若动画进行中,对同一 marker 再次调用 moveAlong 方法,前一次的动画将被打断。 */
|
36 | moveAlong(object)
|
37 |
|
38 | /** 缩放视野展示所有经纬度
|
39 | * @supported weapp
|
40 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.includePoints.html
|
41 | */
|
42 | includePoints(option: MapContext.IncludePointsOption): Promise<TaroGeneral.CallbackResult>
|
43 |
|
44 | /** 获取当前地图的视野范围
|
45 | * @supported weapp
|
46 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.getRegion.html
|
47 | */
|
48 | getRegion(option?: MapContext.GetRegionOption): Promise<MapContext.GetRegionSuccessCallbackResult>
|
49 |
|
50 | /** 获取当前地图的旋转角
|
51 | * @supported weapp
|
52 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.getRotate.html
|
53 | */
|
54 | getRotate(option?: MapContext.GetRotateOption): Promise<MapContext.GetRotateSuccessCallbackResult>
|
55 |
|
56 | /** 获取当前地图的倾斜角
|
57 | * @supported weapp
|
58 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.getSkew.html
|
59 | */
|
60 | getSkew(option?: MapContext.GetSkewOption): Promise<MapContext.GetSkewSuccessCallbackResult>
|
61 |
|
62 | /** 获取当前地图的缩放级别
|
63 | * @supported weapp
|
64 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.getScale.html
|
65 | */
|
66 | getScale(option?: MapContext.GetScaleOption): Promise<MapContext.GetScaleSuccessCallbackResult>
|
67 |
|
68 | /** 设置地图中心点偏移,向后向下为增长,屏幕比例范围(0.25~0.75),默认偏移为[0.5, 0.5]
|
69 | * @supported weapp
|
70 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.setCenterOffset.html
|
71 | */
|
72 | setCenterOffset(option: MapContext.SetCenterOffsetOption): Promise<TaroGeneral.CallbackResult>
|
73 |
|
74 | /** 移除个性化图层。
|
75 | * @supported weapp
|
76 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.removeCustomLayer.html
|
77 | */
|
78 | removeCustomLayer(option: MapContext.RemoveCustomLayerOption): Promise<TaroGeneral.CallbackResult>
|
79 |
|
80 | /** 添加个性化图层。图层创建参考文档
|
81 | * @supported weapp
|
82 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.addCustomLayer.html
|
83 | */
|
84 | addCustomLayer(option: MapContext.AddCustomLayerOption): Promise<TaroGeneral.CallbackResult>
|
85 |
|
86 | /** 创建自定义图片图层,图片会随着地图缩放而缩放。
|
87 | * @supported weapp
|
88 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.addGroundOverlay.html
|
89 | */
|
90 | addGroundOverlay(option: MapContext.AddGroundLayerOption): Promise<TaroGeneral.CallbackResult>
|
91 |
|
92 | /** 添加可视化图层。需要刷新时,interval 可设置的最小值为 15 s。
|
93 | * @supported weapp
|
94 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.addVisualLayer.html
|
95 | */
|
96 | addVisualLayer(option: MapContext.AddVisualLayerOption): Promise<TaroGeneral.CallbackResult>
|
97 |
|
98 | /** 移除可视化图层。
|
99 | * @supported weapp
|
100 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.removeVisualLayer.html
|
101 | */
|
102 | removeVisualLayer(option: MapContext.RemoveVisualLayerOption): Promise<TaroGeneral.CallbackResult>
|
103 |
|
104 | /** 添加弧线,途经点与夹角必须设置一个。途经点必须在起终点有效坐标范围内,否则不能生成正确的弧线,同时设置夹角角度时,以夹角角度为准。夹角定义为起点到终点,与起点外切线逆时针旋转的角度。
|
105 | * @supported weapp
|
106 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.addArc.html
|
107 | */
|
108 | addArc(option: MapContext.AddArcOption): Promise<TaroGeneral.CallbackResult>
|
109 |
|
110 | /** 删除弧线。
|
111 | * @supported weapp
|
112 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.removeArc.html
|
113 | */
|
114 | removeArc(option: MapContext.RemoveArcOption): Promise<TaroGeneral.CallbackResult>
|
115 |
|
116 | /** 限制地图的显示范围。此接口同时会限制地图的最小缩放整数级别。
|
117 | * @supported weapp
|
118 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.setBoundary.html
|
119 | */
|
120 | setBoundary(option: MapContext.SetBoundaryOption): Promise<TaroGeneral.CallbackResult>
|
121 |
|
122 | /** 更新自定义图片图层。
|
123 | * @supported weapp
|
124 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.updateGroundOverlay.html
|
125 | */
|
126 | updateGroundOverlay(option: MapContext.UpdateGroundOverlayOption): Promise<TaroGeneral.CallbackResult>
|
127 |
|
128 | /** 移除自定义图片图层。
|
129 | * @supported weapp
|
130 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.removeGroundOverlay.html
|
131 | */
|
132 | removeGroundOverlay(option: MapContext.RemoveGroundOverlayOption): Promise<TaroGeneral.CallbackResult>
|
133 |
|
134 | /** 获取经纬度对应的屏幕坐标,坐标原点为地图左上角。
|
135 | * @supported weapp
|
136 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.toScreenLocation.html
|
137 | */
|
138 | toScreenLocation(option: MapContext.ToScreenLocationOption): Promise<TaroGeneral.CallbackResult>
|
139 |
|
140 | /** 获取屏幕上的点对应的经纬度,坐标原点为地图左上角。
|
141 | * @supported weapp
|
142 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.fromScreenLocation.html
|
143 | */
|
144 | fromScreenLocation(option: MapContext.FromScreenLocationOption): Promise<TaroGeneral.CallbackResult>
|
145 |
|
146 | /** 拉起地图APP选择导航。
|
147 | * @supported weapp
|
148 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.openMapApp.html
|
149 | */
|
150 | openMapApp(option: MapContext.OpenMapAppOption): Promise<TaroGeneral.CallbackResult>
|
151 |
|
152 | /** 添加 marker。
|
153 | * @supported weapp
|
154 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.addMarkers.html
|
155 | */
|
156 | addMarkers(option: MapContext.AddMarkersOption): Promise<TaroGeneral.CallbackResult>
|
157 |
|
158 | /** 移除 marker。
|
159 | * @supported weapp
|
160 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.removeMarkers.html
|
161 | */
|
162 | removeMarkers(option: MapContext.RemoveMarkersOption): Promise<TaroGeneral.CallbackResult>
|
163 |
|
164 | /** 初始化点聚合的配置,未调用时采用默认配置。
|
165 | * @supported weapp
|
166 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.initMarkerCluster.html
|
167 | */
|
168 | initMarkerCluster(option?: MapContext.InitMarkerClusterOption): Promise<TaroGeneral.CallbackResult>
|
169 |
|
170 | /** 监听地图事件。
|
171 | * @supported weapp
|
172 | * @example
|
173 | * ```tsx
|
174 | * MapContext.on('markerClusterCreate', (res) => {})
|
175 | * MapContext.on('markerClusterClick', (res) => {})
|
176 | * ```
|
177 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.on.html
|
178 | */
|
179 | on(
|
180 | /** 事件名 */
|
181 | event: keyof MapContext.MapEvent,
|
182 | /** 事件的回调函数 */
|
183 | callback: (res: MapContext.MapEvent[keyof MapContext.MapEvent]) => void
|
184 | ): void
|
185 | }
|
186 | namespace MapContext {
|
187 | interface GetCenterLocationOption {
|
188 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
189 | complete?: (res: TaroGeneral.CallbackResult) => void
|
190 | /** 接口调用失败的回调函数 */
|
191 | fail?: (res: TaroGeneral.CallbackResult) => void
|
192 | /** 接口调用成功的回调函数 */
|
193 | success?: (
|
194 | result: GetCenterLocationSuccessCallbackResult,
|
195 | ) => void
|
196 | }
|
197 | interface GetCenterLocationSuccessCallbackResult extends TaroGeneral.CallbackResult {
|
198 | /** 纬度 */
|
199 | latitude: number
|
200 | /** 经度 */
|
201 | longitude: number
|
202 | /** 调用结果 */
|
203 | errMsg: string
|
204 | }
|
205 | interface SetLocMarkerIconOption {
|
206 | /** 图标路径,支持网络路径、本地路径、代码包路径 */
|
207 | iconPath: string
|
208 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
209 | complete?: (res: TaroGeneral.CallbackResult) => void
|
210 | /** 接口调用失败的回调函数 */
|
211 | fail?: (res: TaroGeneral.CallbackResult) => void
|
212 | /** 接口调用成功的回调函数 */
|
213 | success?: (res: TaroGeneral.CallbackResult) => void
|
214 | }
|
215 | interface GetRegionOption {
|
216 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
217 | complete?: (res: TaroGeneral.CallbackResult) => void
|
218 | /** 接口调用失败的回调函数 */
|
219 | fail?: (res: TaroGeneral.CallbackResult) => void
|
220 | /** 接口调用成功的回调函数 */
|
221 | success?: (
|
222 | result: GetRegionSuccessCallbackResult,
|
223 | ) => void
|
224 | }
|
225 | interface GetRegionSuccessCallbackResult extends TaroGeneral.CallbackResult {
|
226 | /** 东北角经纬度 */
|
227 | northeast: MapPosition
|
228 | /** 西南角经纬度 */
|
229 | southwest: MapPosition
|
230 | }
|
231 | interface GetRotateOption {
|
232 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
233 | complete?: (res: TaroGeneral.CallbackResult) => void
|
234 | /** 接口调用失败的回调函数 */
|
235 | fail?: (res: TaroGeneral.CallbackResult) => void
|
236 | /** 接口调用成功的回调函数 */
|
237 | success?: (
|
238 | result: GetRotateSuccessCallbackResult,
|
239 | ) => void
|
240 | }
|
241 | interface GetRotateSuccessCallbackResult extends TaroGeneral.CallbackResult {
|
242 | /** 旋转角 */
|
243 | rotate: number
|
244 | /** 调用结果 */
|
245 | errMsg: string
|
246 | }
|
247 | interface GetScaleOption {
|
248 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
249 | complete?: (res: TaroGeneral.CallbackResult) => void
|
250 | /** 接口调用失败的回调函数 */
|
251 | fail?: (res: TaroGeneral.CallbackResult) => void
|
252 | /** 接口调用成功的回调函数 */
|
253 | success?: (
|
254 | result: GetScaleSuccessCallbackResult,
|
255 | ) => void
|
256 | }
|
257 | interface GetScaleSuccessCallbackResult extends TaroGeneral.CallbackResult {
|
258 | /** 缩放值 */
|
259 | scale: number
|
260 | /** 调用结果 */
|
261 | errMsg: string
|
262 | }
|
263 | interface GetSkewOption {
|
264 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
265 | complete?: (res: TaroGeneral.CallbackResult) => void
|
266 | /** 接口调用失败的回调函数 */
|
267 | fail?: (res: TaroGeneral.CallbackResult) => void
|
268 | /** 接口调用成功的回调函数 */
|
269 | success?: (result: GetSkewSuccessCallbackResult) => void
|
270 | }
|
271 | interface GetSkewSuccessCallbackResult extends TaroGeneral.CallbackResult {
|
272 | /** 倾斜角 */
|
273 | skew: number
|
274 | /** 调用结果 */
|
275 | errMsg: string
|
276 | }
|
277 | interface IncludePointsOption {
|
278 | /** 要显示在可视区域内的坐标点列表 */
|
279 | points: MapPosition[]
|
280 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
281 | complete?: (res: TaroGeneral.CallbackResult) => void
|
282 | /** 接口调用失败的回调函数 */
|
283 | fail?: (res: TaroGeneral.CallbackResult) => void
|
284 | /** 坐标点形成的矩形边缘到地图边缘的距离,单位像素。格式为[上,右,下,左],安卓上只能识别数组第一项,上下左右的padding一致。开发者工具暂不支持padding参数。 */
|
285 | padding?: number[]
|
286 | /** 接口调用成功的回调函数 */
|
287 | success?: (res: TaroGeneral.CallbackResult) => void
|
288 | }
|
289 | /** 坐标点 */
|
290 | interface MapPosition {
|
291 | /** 纬度 */
|
292 | latitude: number
|
293 | /** 经度 */
|
294 | longitude: number
|
295 | }
|
296 | /** 经纬度范围 */
|
297 | interface MapBoundary {
|
298 | /** 西南角经纬度 */
|
299 | southwest: MapPosition
|
300 | /** 东北角经纬度 */
|
301 | northeast: MapPosition
|
302 | }
|
303 | interface MoveToLocationOption {
|
304 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
305 | complete?: (res: TaroGeneral.CallbackResult) => void
|
306 | /** 接口调用失败的回调函数 */
|
307 | fail?: (res: TaroGeneral.CallbackResult) => void
|
308 | /** 纬度 */
|
309 | latitude?: number
|
310 | /** 经度 */
|
311 | longitude?: number
|
312 | /** 接口调用成功的回调函数 */
|
313 | success?: (res: TaroGeneral.CallbackResult) => void
|
314 | }
|
315 | interface TranslateMarkerOption {
|
316 | /** 移动过程中是否自动旋转 marker */
|
317 | autoRotate: boolean
|
318 | /** 指定 marker 移动到的目标点 */
|
319 | destination: MapPosition
|
320 | /** 指定 marker */
|
321 | markerId: number
|
322 | /** marker 的旋转角度 */
|
323 | rotate: number
|
324 | /** 动画结束回调函数 */
|
325 | animationEnd?: (...args: any[]) => any
|
326 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
327 | complete?: (res: TaroGeneral.CallbackResult) => void
|
328 | /** 动画持续时长,平移与旋转分别计算 */
|
329 | duration?: number
|
330 | /** 接口调用失败的回调函数 */
|
331 | fail?: (res: TaroGeneral.CallbackResult) => void
|
332 | /** 接口调用成功的回调函数 */
|
333 | success?: (res: TaroGeneral.CallbackResult) => void
|
334 | }
|
335 | interface SetCenterOffsetOption {
|
336 | /** 偏移量,两位数组 */
|
337 | offset: number[]
|
338 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
339 | complete?: (res: TaroGeneral.CallbackResult) => void
|
340 | /** 接口调用失败的回调函数 */
|
341 | fail?: (res: TaroGeneral.CallbackResult) => void
|
342 | /** 接口调用成功的回调函数 */
|
343 | success?: (res: TaroGeneral.CallbackResult) => void
|
344 | }
|
345 | interface RemoveCustomLayerOption {
|
346 | /** 个性化图层id */
|
347 | layerId: number
|
348 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
349 | complete?: (res: TaroGeneral.CallbackResult) => void
|
350 | /** 接口调用失败的回调函数 */
|
351 | fail?: (res: TaroGeneral.CallbackResult) => void
|
352 | /** 接口调用成功的回调函数 */
|
353 | success?: (res: TaroGeneral.CallbackResult) => void
|
354 | }
|
355 | interface AddCustomLayerOption {
|
356 | /** 个性化图层id */
|
357 | layerId: number
|
358 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
359 | complete?: (res: TaroGeneral.CallbackResult) => void
|
360 | /** 接口调用失败的回调函数 */
|
361 | fail?: (res: TaroGeneral.CallbackResult) => void
|
362 | /** 接口调用成功的回调函数 */
|
363 | success?: (res: TaroGeneral.CallbackResult) => void
|
364 | }
|
365 | interface AddGroundLayerOption {
|
366 | /** 图片图层 id */
|
367 | id: number
|
368 | /** 图片路径,支持网络图片、临时路径、代码包路径 */
|
369 | src: string
|
370 | /** 图片覆盖的经纬度范围 */
|
371 | bounds: MapBoundary
|
372 | /** 是否可见
|
373 | * @default true
|
374 | */
|
375 | visible?: boolean
|
376 | /** 图层绘制顺序
|
377 | * @default 1
|
378 | */
|
379 | zIndex?: number
|
380 | /** 图层透明度
|
381 | * @default 1
|
382 | */
|
383 | opacity?: number
|
384 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
385 | complete?: (res: TaroGeneral.CallbackResult) => void
|
386 | /** 接口调用失败的回调函数 */
|
387 | fail?: (res: TaroGeneral.CallbackResult) => void
|
388 | /** 接口调用成功的回调函数 */
|
389 | success?: (res: TaroGeneral.CallbackResult) => void
|
390 | }
|
391 | interface AddVisualLayerOption {
|
392 | /** 个性化图层id([创建图层指引](https://lbs.qq.com/dev/console/layers/layerEdit)) */
|
393 | layerId: number
|
394 | /** 刷新周期,单位秒
|
395 | * @default 0
|
396 | */
|
397 | interval?: number
|
398 | /** 图层绘制顺序
|
399 | * @default 1
|
400 | */
|
401 | zIndex?: number
|
402 | /** 图层透明度
|
403 | * @default 1
|
404 | */
|
405 | opacity?: number
|
406 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
407 | complete?: (res: TaroGeneral.CallbackResult) => void
|
408 | /** 接口调用失败的回调函数 */
|
409 | fail?: (res: TaroGeneral.CallbackResult) => void
|
410 | /** 接口调用成功的回调函数 */
|
411 | success?: (res: TaroGeneral.CallbackResult) => void
|
412 | }
|
413 | interface RemoveVisualLayerOption {
|
414 | /** 可视化图层 id */
|
415 | layerId: number
|
416 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
417 | complete?: (res: TaroGeneral.CallbackResult) => void
|
418 | /** 接口调用失败的回调函数 */
|
419 | fail?: (res: TaroGeneral.CallbackResult) => void
|
420 | /** 接口调用成功的回调函数 */
|
421 | success?: (res: TaroGeneral.CallbackResult) => void
|
422 | }
|
423 | interface AddArcOption {
|
424 | /** 圆弧 id */
|
425 | id: number
|
426 | /** 起始点 */
|
427 | start: MapPosition
|
428 | /** 终点 */
|
429 | end: MapPosition
|
430 | /** 途经点 */
|
431 | pass?: MapPosition
|
432 | /** 夹角角度
|
433 | * @default 0
|
434 | */
|
435 | angle?: number
|
436 | /** 线宽
|
437 | * @default 5
|
438 | */
|
439 | width?: number
|
440 | /** 线的颜色
|
441 | * @default "#000000"
|
442 | */
|
443 | color?: string
|
444 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
445 | complete?: (res: TaroGeneral.CallbackResult) => void
|
446 | /** 接口调用失败的回调函数 */
|
447 | fail?: (res: TaroGeneral.CallbackResult) => void
|
448 | /** 接口调用成功的回调函数 */
|
449 | success?: (res: TaroGeneral.CallbackResult) => void
|
450 | }
|
451 | interface RemoveArcOption {
|
452 | /** 圆弧 id */
|
453 | id: number
|
454 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
455 | complete?: (res: TaroGeneral.CallbackResult) => void
|
456 | /** 接口调用失败的回调函数 */
|
457 | fail?: (res: TaroGeneral.CallbackResult) => void
|
458 | /** 接口调用成功的回调函数 */
|
459 | success?: (res: TaroGeneral.CallbackResult) => void
|
460 | }
|
461 | interface SetBoundaryOption {
|
462 | /** 西南角经纬度 */
|
463 | southwest: MapPosition
|
464 | /** 东北角经纬度 */
|
465 | northeast: MapPosition
|
466 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
467 | complete?: (res: TaroGeneral.CallbackResult) => void
|
468 | /** 接口调用失败的回调函数 */
|
469 | fail?: (res: TaroGeneral.CallbackResult) => void
|
470 | /** 接口调用成功的回调函数 */
|
471 | success?: (res: TaroGeneral.CallbackResult) => void
|
472 | }
|
473 | interface UpdateGroundOverlayOption {
|
474 | /** 图片图层 id */
|
475 | id: number
|
476 | /** 图片路径,支持网络图片、临时路径、代码包路径 */
|
477 | src: string
|
478 | /** 图片覆盖的经纬度范围 */
|
479 | bounds: MapBoundary
|
480 | /** 是否可见
|
481 | * @default true
|
482 | */
|
483 | visible?: boolean
|
484 | /** 图层绘制顺序
|
485 | * @default 1
|
486 | */
|
487 | zIndex?: number
|
488 | /** 图层透明度
|
489 | * @default 1
|
490 | */
|
491 | opacity?: number
|
492 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
493 | complete?: (res: TaroGeneral.CallbackResult) => void
|
494 | /** 接口调用失败的回调函数 */
|
495 | fail?: (res: TaroGeneral.CallbackResult) => void
|
496 | /** 接口调用成功的回调函数 */
|
497 | success?: (res: TaroGeneral.CallbackResult) => void
|
498 | }
|
499 | interface RemoveGroundOverlayOption {
|
500 | /** 图片图层 id */
|
501 | id: number
|
502 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
503 | complete?: (res: TaroGeneral.CallbackResult) => void
|
504 | /** 接口调用失败的回调函数 */
|
505 | fail?: (res: TaroGeneral.CallbackResult) => void
|
506 | /** 接口调用成功的回调函数 */
|
507 | success?: (res: TaroGeneral.CallbackResult) => void
|
508 | }
|
509 | interface ToScreenLocationOption {
|
510 | /** 纬度 */
|
511 | latitude: number
|
512 | /** 经度 */
|
513 | longitude: number
|
514 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
515 | complete?: (res: TaroGeneral.CallbackResult) => void
|
516 | /** 接口调用失败的回调函数 */
|
517 | fail?: (res: TaroGeneral.CallbackResult) => void
|
518 | /** 接口调用成功的回调函数 */
|
519 | success?: (res: TaroGeneral.CallbackResult) => void
|
520 | }
|
521 | interface FromScreenLocationOption {
|
522 | /** x 坐标值 */
|
523 | x: number
|
524 | /** y 坐标值 */
|
525 | y: number
|
526 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
527 | complete?: (res: TaroGeneral.CallbackResult) => void
|
528 | /** 接口调用失败的回调函数 */
|
529 | fail?: (res: TaroGeneral.CallbackResult) => void
|
530 | /** 接口调用成功的回调函数 */
|
531 | success?: (res: TaroGeneral.CallbackResult) => void
|
532 | }
|
533 | interface OpenMapAppOption {
|
534 | /** 目的地经度 */
|
535 | longitude: number
|
536 | /** 目的地纬度 */
|
537 | latitude: number
|
538 | /** 目的地名称 */
|
539 | destination: string
|
540 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
541 | complete?: (res: TaroGeneral.CallbackResult) => void
|
542 | /** 接口调用失败的回调函数 */
|
543 | fail?: (res: TaroGeneral.CallbackResult) => void
|
544 | /** 接口调用成功的回调函数 */
|
545 | success?: (res: TaroGeneral.CallbackResult) => void
|
546 | }
|
547 | interface AddMarkersOption {
|
548 | /** 同传入 map 组件的 marker 属性 */
|
549 | markers: MapProps.marker[]
|
550 | /** 是否先清空地图上所有 marker
|
551 | * @default false
|
552 | */
|
553 | clear?: boolean
|
554 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
555 | complete?: (res: TaroGeneral.CallbackResult) => void
|
556 | /** 接口调用失败的回调函数 */
|
557 | fail?: (res: TaroGeneral.CallbackResult) => void
|
558 | /** 接口调用成功的回调函数 */
|
559 | success?: (res: TaroGeneral.CallbackResult) => void
|
560 | }
|
561 | interface RemoveMarkersOption {
|
562 | /** marker 的 id 集合。 */
|
563 | markerIds: string[]
|
564 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
565 | complete?: (res: TaroGeneral.CallbackResult) => void
|
566 | /** 接口调用失败的回调函数 */
|
567 | fail?: (res: TaroGeneral.CallbackResult) => void
|
568 | /** 接口调用成功的回调函数 */
|
569 | success?: (res: TaroGeneral.CallbackResult) => void
|
570 | }
|
571 | interface InitMarkerClusterOption {
|
572 | /** 启用默认的聚合样式
|
573 | * @default true
|
574 | */
|
575 | enableDefaultStyle?: boolean
|
576 | /** 点击已经聚合的标记点时是否实现聚合分离
|
577 | * @default true
|
578 | */
|
579 | zoomOnClick?: boolean
|
580 | /** 聚合算法的可聚合距离,即距离小于该值的点会聚合至一起,以像素为单位
|
581 | * @default 60
|
582 | */
|
583 | gridSize?: number
|
584 | /** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
585 | complete?: (res: TaroGeneral.CallbackResult) => void
|
586 | /** 接口调用失败的回调函数 */
|
587 | fail?: (res: TaroGeneral.CallbackResult) => void
|
588 | /** 接口调用成功的回调函数 */
|
589 | success?: (res: TaroGeneral.CallbackResult) => void
|
590 | }
|
591 | /** event 的合法值 */
|
592 | interface MapEvent {
|
593 | /** 缩放或拖动导致新的聚合簇产生时触发,仅返回新创建的聚合簇信息 */
|
594 | markerClusterCreate: MapEventMarkerClusterCreate
|
595 | /** 聚合簇的点击事件 */
|
596 | markerClusterClick: MapEventMarkerClusterClick
|
597 | }
|
598 | interface MapEventMarkerClusterCreate {
|
599 | /** 聚合簇数据 */
|
600 | clusters: ClusterInfo[]
|
601 | }
|
602 | interface MapEventMarkerClusterClick {
|
603 | /** 聚合簇 */
|
604 | cluster: ClusterInfo
|
605 | }
|
606 | interface ClusterInfo {
|
607 | /** 聚合簇的 id */
|
608 | clusterId: number
|
609 | /** 聚合簇的坐标 */
|
610 | center: LatLng
|
611 | /** 该聚合簇内的点标记数据数组 */
|
612 | markerIds: string[]
|
613 | }
|
614 | interface LatLng {
|
615 | /** 纬度值 */
|
616 | lat: number
|
617 | /** 经度值 */
|
618 | lng: number
|
619 | }
|
620 | }
|
621 |
|
622 | interface TaroStatic {
|
623 | /** 创建 [map](/docs/components/maps/map) 上下文 [MapContext](/docs/apis/media/map/MapContext) 对象。
|
624 | * @supported weapp
|
625 | * @example
|
626 | * ```tsx
|
627 | * const mapCtx = Taro.createMapContext('myMap')
|
628 | * ```
|
629 | * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/map/wx.createMapContext.html
|
630 | */
|
631 | createMapContext(
|
632 | /** Map 组件的 id */
|
633 | mapId: string,
|
634 | /** 在自定义组件下,当前组件实例的this,以操作组件内 Map 组件 */
|
635 | component?: TaroGeneral.IAnyObject,
|
636 | ): MapContext
|
637 | }
|
638 | }
|