Reason Pun

修复google map定位问题

...@@ -39,6 +39,7 @@ class AddressSelectPageState extends State<AddressSelectPage> { ...@@ -39,6 +39,7 @@ class AddressSelectPageState extends State<AddressSelectPage> {
39 @override 39 @override
40 void initState() { 40 void initState() {
41 super.initState(); 41 super.initState();
42 + _getCurrentLocation();
42 } 43 }
43 44
44 Future<void> _getCurrentLocation() async { 45 Future<void> _getCurrentLocation() async {
...@@ -64,28 +65,22 @@ class AddressSelectPageState extends State<AddressSelectPage> { ...@@ -64,28 +65,22 @@ class AddressSelectPageState extends State<AddressSelectPage> {
64 _locationSubscription = 65 _locationSubscription =
65 location.onLocationChanged.listen((LocationData currentLocation) { 66 location.onLocationChanged.listen((LocationData currentLocation) {
66 _center = LatLng(currentLocation.latitude!, currentLocation.longitude!); 67 _center = LatLng(currentLocation.latitude!, currentLocation.longitude!);
68 + });
69 + }
67 70
71 + void _onMapCreated(GoogleMapController controller) {
72 + mapController = controller;
68 final String markerIdVal = 'marker_id_$_markerIdCounter'; 73 final String markerIdVal = 'marker_id_$_markerIdCounter';
69 _markerIdCounter++; 74 _markerIdCounter++;
70 final MarkerId markerId = MarkerId(markerIdVal); 75 final MarkerId markerId = MarkerId(markerIdVal);
71 -
72 final Marker marker = Marker( 76 final Marker marker = Marker(
73 markerId: markerId, 77 markerId: markerId,
74 - position: LatLng(currentLocation.latitude!, currentLocation.longitude!), 78 + position: _center,
75 ); 79 );
76 - 80 + mapController.moveCamera(CameraUpdate.newLatLng(_center));
77 - LatLng sydney =
78 - LatLng(currentLocation.latitude!, currentLocation.longitude!);
79 - mapController.moveCamera(CameraUpdate.newLatLng(sydney));
80 setState(() { 81 setState(() {
81 markers[markerId] = marker; 82 markers[markerId] = marker;
82 }); 83 });
83 - });
84 - }
85 -
86 - void _onMapCreated(GoogleMapController controller) {
87 - mapController = controller;
88 - _getCurrentLocation();
89 } 84 }
90 85
91 @override 86 @override
......