【问题标题】:How to use location markers as buttons in Flutter?如何在 Flutter 中使用位置标记作为按钮?
【发布时间】:2020-05-23 04:43:01
【问题描述】:

我正在开发一个运输(资产)跟踪应用程序。并使用谷歌地图插件在谷歌地图中显示他们所有不同的资产。当用户单击资产的当前位置标记时,我想显示有关资产的信息。在 simpleton 中,我想将位置标记用作按钮。如果有任何其他方法可以实现这一点,请分享。

【问题讨论】:

    标签: google-maps flutter dart flutter-layout


    【解决方案1】:

    必须有一些添加标记的代码,如下所示,只需添加onTap

    markers.add(
                Marker(
                  zIndex: 100,
                    markerId: MarkerId(myList[i].code),
                    position: LatLng(myList[i].latitude, myList[i].longitude),
                    icon: BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueRed)
    
                    ),
                    onTap: () {
                      //this is what you're looking for!
                      setState(() {
                        currCode=myList[i].code;
                        //call something here with myList[i].code or store in global constant for widget state
    
                      });
    
                    }
                )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-11
      • 2020-11-09
      相关资源
      最近更新 更多