我有一个Flutter应用程序,其中map
显示user location
在模拟器上,当我更改coords
时,标记会移动。
但是,在物理设备上,它根本不会移动。
我有一个地理定位器Stream
来更新标记位置
这是我的代码
Position? currentPosition;
StreamSubscription<Position>? positionStream;
void listenToLocationChanges() {
LocationIndicator locationIndicator = LocationIndicator();
locationIndicator.locationIndicatorStyle = LocationIndicatorIndicatorStyle.pedestrian;
final LocationSettings locationSettings = LocationSettings(
accuracy: LocationAccuracy.high,
distanceFilter: 100,
);
positionStream = Geolocator.getPositionStream(locationSettings: locationSettings).listen(
(Position? position) {
print(position==null? 'Unknown' : '$position');
currentPosition = position;
GeoCoordinates geoCoordinates = GeoCoordinates (position!.latitude, position.longitude);
bearing = position.heading;
currentlat = position.latitude;
currentlong = position.longitude;
Location location = Location.withCoordinates(geoCoordinates);
location.time = DateTime.now();
location.bearingInDegrees = bearing;
locationIndicator.updateLocation(location);
_hereMapController.addLifecycleListener(locationIndicator);
_locationIndicatorList.add(locationIndicator);
},
);
}
当我改变自定义坐标时,它会在我的模拟器中工作,它更新得很好,但在设备上,它在打开时仍停留在该位置,这有什么原因吗?
先谢了
1条答案
按热度按时间ckx4rj1h1#
我更改了距离参数,现在是准确的