google_maps_flutter as a tab flakey in iOS

42 views
Skip to first unread message

hoek

unread,
Dec 29, 2018, 6:40:02 PM12/29/18
to Flutter Dev
Hi,
all.

The map widget as one of three tabs works well in Android.

In iOS:
When you switch tags by dragging your finger it SOMETIMES shows the wrong zoom and location.
It continues to do this when you click the "Go to London" button.
IE it is in a bad state.

(It works well when you switch tabs by touching their labels at the top.)

Am I using the wrong call in
void _onMapCreated(GoogleMapController controller) {
?

Seems like it is a bug...

//main.dart fragment:
body
: TabBarView(
            children
: [
             
WidgetB(),
             
WidgetA(),
             
MapWidget(),
           
],
         
),
         
         
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';


class MapWidget extends StatefulWidget {
 
@override
 
State createState() => MapWidgetState();
}

class MapWidgetState extends State<MapWidget> {

 
GoogleMapController mapController;
 
 
@override
 
Widget build(BuildContext context) {
   
return Padding(
      padding
: EdgeInsets.all(15.0),
      child
: Column(
        mainAxisAlignment
: MainAxisAlignment.spaceEvenly,
        children
: <Widget>[
         
Center(
            child
: SizedBox(
              width
: 300.0,
              height
: 200.0,
              child
: GoogleMap(
                onMapCreated
: _onMapCreated,
             
),
           
),
         
),
         
RaisedButton(
            child
: const Text('Go to London'),
            onPressed
: mapController == null ? null : () {
              mapController
.animateCamera(CameraUpdate.newCameraPosition(
               
CameraPosition(
                  bearing
: 270.0,
                  target
: LatLng(51.5160895, -0.1294527),//London location
                  tilt
: 30.0,
                  zoom
: 17.0,
               
),
             
));
           
},
         
),
       
],
     
),
   
);
 
}

 
void _onMapCreated(GoogleMapController controller) {
    setState
(() { mapController = controller; });
 
   
CameraPosition cameraPosition = CameraPosition(
                  target
: LatLng(51.5160895+2, -0.1294527-1), //Fish Bits location
                  zoom
: 17.0,
               
);

     
var cameraUpdate = CameraUpdate.newCameraPosition(cameraPosition);
     mapController
.moveCamera(cameraUpdate);
 
}
}



Amir Hardon

unread,
Jan 2, 2019, 12:59:14 PM1/2/19
to hoek, Flutter Dev

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages