Commit 9688deed authored by 7c00's avatar 7c00

定位新增返回速度、时间戳、海拔数据

parent 9dfeeddc
......@@ -50,6 +50,9 @@ class AMapView(context: Context) : TextureMapView(context) {
event.putDouble("latitude", location.latitude)
event.putDouble("longitude", location.longitude)
event.putDouble("accuracy", location.accuracy.toDouble())
event.putDouble("altitude", location.altitude)
event.putDouble("speed", location.speed.toDouble())
event.putInt("timestamp", location.time.toInt())
emit(id, "onLocation", event)
}
......
......@@ -98,6 +98,9 @@ RCT_EXPORT_METHOD(animateTo:(nonnull NSNumber *)reactTag params:(NSDictionary *)
@"latitude": @(userLocation.coordinate.latitude),
@"longitude": @(userLocation.coordinate.longitude),
@"accuracy": @((userLocation.location.horizontalAccuracy + userLocation.location.verticalAccuracy) / 2),
@"altitude": @(userLocation.location.altitude),
@"speed": @(userLocation.location.speed),
@"timestamp": @(userLocation.location.timestamp.timeIntervalSince1970),
});
}
}
......@@ -194,7 +197,7 @@ RCT_EXPORT_METHOD(animateTo:(nonnull NSNumber *)reactTag params:(NSDictionary *)
mapView.loaded = YES;
// struct 里的值会被初始化为 0,这里以此作为条件,判断 initialRegion 是否被设置过
// 但实际上经度为 0 是一个合法的坐标(赤道),只是考虑到高德地图只在中国使用,就这样吧
// 但实际上经度为 0 是一个合法的坐标,只是考虑到高德地图只在中国使用,就这样吧
if (mapView.initialRegion.center.latitude != 0) {
mapView.region = mapView.initialRegion;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment