我试图设置一个更改设置函数到我的getLocation()没有幸运。我当前的位置已经更新了,不管我移动与否,是什么导致了变量的噪音。我可能错误地定义了我的更改设置功能,如果使用文档页面提供的功能说LocationAccuracy没有定义。
void getCurrentLocation() async {
try {
Uint8List imageData = await getMarker();
var location = await _locationTracker.getLocation();
if (_locationSubscription != null) {
_locationSubscription.cancel();
}
updateMarkerAndCircle(location, imageData);
location.changeSettings(interval: 3000, distanceFilter: 10.0);
_locationSubscription =
_locationTracker.onLocationChanged().listen((newLocalData) {
if (_controller != null) {
_controller.animateCamera(CameraUpdate.newCameraPosition(
new CameraPosition(
bearing: 192.8334901395799,
target: LatLng(newLocalData.latitude, newLocalData.longitude),
tilt: 0,
zoom: 18.00)));
updateMarkerAndCircle(newLocalData, imageData);
}
routesCoordinates.currentLocation =
LatLng(newLocalData.latitude, newLocalData.longitude);
if (routesCoordinates.inCourse) {
routesCoordinates.upDateCurrentLocation();
routesCoordinates.latlngSendBackEnd.add({
"lat_lng": LatLng(newLocalData.latitude, newLocalData.longitude),
"date": DateTime.now().toString(),
});
drawPolyLine.latlng
.add(LatLng(newLocalData.latitude, newLocalData.longitude));
drawPolyLine.drawPolyLine();
}
});
} on PlatformException catch (e) {
if (e.code == 'PERMISSION_DENIED') {
debugPrint("Permission Denied");
}
}
}
任何帮助、建议或指导都将不胜感激。
我刚刚解决了,文档上的sintaxe是错误的。
Future<bool> changeSettings({
LocationAccuracy accuracy = LocationAccuracy.HIGH,
int interval = 1000,
double distanceFilter = 5,
}) {
return _locationTracker.changeSettings(
accuracy: accuracy,
interval: interval,
distanceFilter: distanceFilter,
);
}
LocationAccuracy accuracy = LocationAccuracy。高,
"引起;必须大写
try wordawait在changeSettings命令
await location.changeSettings(interval: 3000, distanceFilter: 10.0);