UNPKG

taro-hooks

Version:
29 lines (28 loc) 1.48 kB
import type { MapContext } from '@tarojs/taro'; import type { WithUndefind, PromiseOptionalAction, PromiseParamsAction, PromiseAction, ExcludeOption, UnionResult } from '../type'; export type Marker = MapContext.AddMarkersOption['markers']; export type GetSuccessCallbackResult = { center: UnionResult<MapContext.GetCenterLocationSuccessCallbackResult>; region: UnionResult<MapContext.GetRegionSuccessCallbackResult>; rotate: UnionResult<MapContext.GetRotateSuccessCallbackResult>; scale: UnionResult<MapContext.GetScaleSuccessCallbackResult>; skew: UnionResult<MapContext.GetSkewSuccessCallbackResult>; }; export type Get = PromiseOptionalAction<string, GetSuccessCallbackResult>; export type Open = PromiseAction<ExcludeOption<MapContext.OpenMapAppOption>>; export type Include = PromiseParamsAction<(points: MapContext.MapPosition[], padding?: number[]) => void>; export type MoveTo = PromiseOptionalAction<ExcludeOption<MapContext.MoveToLocationOption>>; export type Translate = PromiseAction<ExcludeOption<MapContext.TranslateMarkerOption>>; export type ToggleMarkers = PromiseParamsAction<(markers: Marker | number[], clear?: boolean) => void>; declare function useMap<R = TaroGeneral.IAnyObject>(mapId: string, component?: R): [ WithUndefind<MapContext>, { get: Get; open: Open; include: Include; moveTo: MoveTo; translate: Translate; toggleMarkers: ToggleMarkers; } ]; export default useMap;