我使用的是bellow小部件,我想在 map 视图中将我的位置按钮改为底部位置

GoogleMap(

                  onMapCreated: onMapCreated,

              options: GoogleMapOptions(


                    myLocationEnabled :true, 
                    mapType: MapType.hybrid,

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

推荐答案

我找到了解决办法.我创建FAB按钮来更改我的位置按钮

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方法来调用我的位置

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,
      ),
    ));
  }

Flutter相关问答推荐

如何使用底部导航栏修复此导航问题

无法将Flutter 连接到Firebase

Dexing时出错.将Flutter 升级到3.19.0后

Flutter 应用程序中的Firebase实时数据库中的orderByChild()不适用于我

Flutter 翼future 建造者不断开火和重建.它在每次重建时都会生成一个新的随机数--我如何防止这种情况?

如果我使用搜索栏,如何在嵌套滚动视图中停止自动滚动?

如何手动将 FirebaseAuth 用户邮箱验证状态设置为 true

如何在 Flutter 中以背景 colored颜色 制作圆圈的一部分

Flutter:如何在现有布局之上显示圆角布局?

「Flutter」错误:没有名为'kind'的命名参数

Flutter屏幕适配 - 在模拟器和真实手机上文本尺寸不同

Paypal 支付网关添加带有 magento 2 网络详细信息用户名、密码、签名 Magento 2 的 flutter 应用程序?

如何在两个不同的路由(屏幕)之间正确设置 BlocProvider?

如何将金钱格式化为数以百万计的Flutter 动?

无法在 flutter 中更新 void 方法内的变量值

我可以使用 Future 来填充Text() 小部件而不是在 Flutter 中使用 FutureBuilder 吗?

Flutter 用户过滤器

try 为两个下拉值添加共享首选项,但在 Flutter 上显示错误断言失败:?

单击列表视图导航到 Flutter 中的另一个页面

Flutter:如何将 AssetImage 转换为 Unit8List?