Mapview是一个类,我将在其中显示用户车辆的位置,在这种情况下,我必须显示该车辆的实时跟踪,以获取必须更新摄像机位置的信息。我该怎么办?
mapView.show(
new MapOptions(
mapViewType: MapViewType.normal,
initialCameraPosition: new CameraPosition(new Location(lattitude,longitude), 17.0),
showUserLocation: true,
showCompassButton: true,
showMyLocationButton: true,
title:_vehicleNumbers[0].toString(),
),
toolbarActions: [
ToolbarAction('Close',1),
]
);
答案 0 :(得分:1)
您需要以某种方式监视用户设备的位置。飞镖酒吧上有一个不错的位置信息包... Flutter Location Package
这提供了位置更新的回调。然后,您需要在mapView对象上调用setCameraPosition
函数以更新视图:
var location = new Location();
location.onLocationChanged.listen((Map<String,double> currentLocation) {
var latitude = currentLocation["latitude"];
var longitude = currentLocation["longitude"];
mapView.setCameraPosition(new CameraPosition(new Location(lattitude,longitude), 17.0));
});
希望这会有所帮助。