gpt4 book ai didi

google-maps - flutter 谷歌地图 : How can you change maptype after runtime?

转载 作者:行者123 更新时间:2023-12-05 08:30:35 24 4
gpt4 key购买 nike

按下按钮时,我正尝试从 normal 更改为 satellite,但我收到 setMapType 不存在的错误消息。

mapController.setMapType(MapType.satellite);

谁知道我做错了什么?

最佳答案

  1. 创建一个 MapType 变量:

    MapType _currentMapType = MapType.normal;
  2. 调用您的 Google map 小部件时引用此变量:

    googleMap = new GoogleMap(
    mapType: _currentMapType,
    //etc
  3. 创建一个 float 按钮小部件来切换 map 类型:

    floatingActionButton: FloatingActionButton(           
    child: Icon(Icons.layers),
    onPressed: ()=>
    {
    setState(() {
    _currentMapType = (_currentMapType == MapType.normal) ? MapType.satellite : MapType.normal;
    });
    },
    heroTag: null,
    ),

关于google-maps - flutter 谷歌地图 : How can you change maptype after runtime?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63430486/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com