如何在颤抖中更改Google Map API的“我的位置"按钮位置?

问题描述:

我使用的是波纹管小部件,我想将我的位置"按钮更改为我的地图视图中的底部位置

I'm using bellow widget,I want to change MyLocation button get to bottom position in my map view

GoogleMap(

                  onMapCreated: onMapCreated,

              options: GoogleMapOptions(


                    myLocationEnabled :true, 
                    mapType: MapType.hybrid,

                  cameraPosition: CameraPosition(
                    target: LatLng(6.8814635,79.8876697),
                    zoom: 15.0,),
                  ),
    ),

我找到了解决方案.我创建了FAB按钮来更改我的位置"按钮

I found the solution. I create FAB button to change My Location button

GoogleMap(
        mapType: MapType.hybrid,
        initialCameraPosition: _kGooglePlex,
        onMapCreated: (GoogleMapController controller) {
          _controller.complete(controller);
        },
        myLocationEnabled: true,
      ),
      floatingActionButton: FloatingActionButton.extended(
        onPressed: _currentLocation,
        label: Text('My Location'),
        icon: Icon(Icons.location_on),
      ),
    );
  }

还要设置 _currentLocation 方法以调用我的位置

also, set the _currentLocation method to call my location

void _currentLocation() async {
   final GoogleMapController controller = await _controller.future;
   LocationData currentLocation;
   var location = new Location();
   try {
     currentLocation = await location.getLocation();
     } on Exception {
       currentLocation = null;
       }

    controller.animateCamera(CameraUpdate.newCameraPosition(
      CameraPosition(
        bearing: 0,
        target: LatLng(currentLocation.latitude, currentLocation.longitude),
        zoom: 17.0,
      ),
    ));
  }