Reason Pun

修复google map定位问题

......@@ -39,6 +39,7 @@ class AddressSelectPageState extends State<AddressSelectPage> {
@override
void initState() {
super.initState();
_getCurrentLocation();
}
Future<void> _getCurrentLocation() async {
......@@ -64,28 +65,22 @@ class AddressSelectPageState extends State<AddressSelectPage> {
_locationSubscription =
location.onLocationChanged.listen((LocationData currentLocation) {
_center = LatLng(currentLocation.latitude!, currentLocation.longitude!);
});
}
void _onMapCreated(GoogleMapController controller) {
mapController = controller;
final String markerIdVal = 'marker_id_$_markerIdCounter';
_markerIdCounter++;
final MarkerId markerId = MarkerId(markerIdVal);
final Marker marker = Marker(
markerId: markerId,
position: LatLng(currentLocation.latitude!, currentLocation.longitude!),
position: _center,
);
LatLng sydney =
LatLng(currentLocation.latitude!, currentLocation.longitude!);
mapController.moveCamera(CameraUpdate.newLatLng(sydney));
mapController.moveCamera(CameraUpdate.newLatLng(_center));
setState(() {
markers[markerId] = marker;
});
});
}
void _onMapCreated(GoogleMapController controller) {
mapController = controller;
_getCurrentLocation();
}
@override
......