Skip to content

Commit 906048f

Browse files
committed
feat(iOS): Add setPausesLocationUpdatesAutomatically props.
1 parent 114a756 commit 906048f

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ export function coordinateConvert(coordinate: Point, type: -1 | 0 | 1 | 2 | 3 |
188188
* @default 2000
189189
*/
190190
export function setInterval(interval: number): void;
191+
/**
192+
* 指定定位是否会被系统自动暂停。默认为 false
193+
* @platform ios
194+
*/
195+
export function setPausesLocationUpdatesAutomatically(value: boolean = false): void;
191196
/**
192197
* 设定定位的最小更新距离。单位米,默认,表示只要检测到设备位置发生变化就会更新位置信息。
193198
* @platform ios

index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,15 @@ export default class AMapGeolocation {
148148
return NativeModules.RNAMapGeolocation.setDistanceFilter(time);
149149
}
150150
}
151+
/**
152+
* 指定定位是否会被系统自动暂停。默认为 false
153+
* @platform ios
154+
*/
155+
static setPausesLocationUpdatesAutomatically(value = false) {
156+
if (Platform.OS === "ios") {
157+
return NativeModules.RNAMapGeolocation.setPausesLocationUpdatesAutomatically(value);
158+
}
159+
}
151160
/**
152161
* 设置发起定位请求的时间间隔,单位:毫秒,默认值:2000毫秒
153162
* @platform android

ios/RNAMapGeolocation.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ - (instancetype)init {
123123
_manager.reGeocodeLanguage = (AMapLocationReGeocodeLanguage)value;
124124
}
125125

126+
// 指定定位是否会被系统自动暂停。默认为NO。
127+
RCT_EXPORT_METHOD(setPausesLocationUpdatesAutomatically: (BOOL)value) {
128+
_manager.pausesLocationUpdatesAutomatically = value;
129+
}
130+
126131
/**
127132
* @brief 转换目标经纬度为高德坐标系,不在枚举范围内的经纬度将直接返回。
128133
* @param coordinate 待转换的经纬度

0 commit comments

Comments
 (0)