开始连续定位。
定位请求配置对象。
定位成功回调函数。
定位失败回调函数。
const request = TencentLocationRequest.default().setInterval(5)
locationManager?.startContinuousLocation(request, location => {
console.info('连续定位结果:', JSON.stringify(location))
}, error => {
console.error('连续定位失败:', JSON.stringify(error))
})
1.0.0
开始接收设备状态变化通知。
设备状态变化回调函数。
1.0.0
开始单次定位。
定位请求配置对象。
定位成功回调函数。
定位失败回调函数。
const request = TencentLocationRequest.default().setSingleLocationTimeout(10)
locationManager?.startSingleLocation(request, location => {
console.info('单次定位结果:', JSON.stringify(location))
}, error => {
console.error('单次定位失败:', JSON.stringify(error))
})
1.0.0
获取最后一次缓存的定位结果。
SDK 会缓存最后一个回调给开发者的定位结果,该值有可能为 undefined。
最后一次定位结果,如果没有缓存则返回 undefined。
const lastLocation = locationManager?.getLastLocation()
console.info('最后位置:', JSON.stringify(lastLocation))
1.0.0
添加地理围栏。
地理围栏请求配置对象。
Promise 对象,成功时返回围栏 ID。
const geofenceRequest = new TencentGeofenceRequest(...)
locationManager?.addGeofence(geofenceRequest).then(geofenceID => {
console.info('围栏添加成功, ID:', geofenceID)
}).catch(error => {
console.error('围栏添加失败:', JSON.stringify(error))
})
1.0.2
腾讯定位服务管理接口,提供连续定位、单次定位、设备状态监听、地理围栏等核心功能。
Author
Tencent Location Team
Since
1.0.0