【问题标题】:Show coordinates by tapping on the map通过点击地图显示坐标
【发布时间】:2020-07-07 19:52:15
【问题描述】:

我想要一个在我按下地图时显示坐标的应用程序。所以我将谷歌地图集成到我的应用程序中,并尝试用下面的代码显示坐标。 print(cordinate); 有效,但是当我想在屏幕上打印坐标时它不起作用。

代码如下:

var test = 0;

  body: Column(
      children: <Widget>[
        Container(
          width: double.infinity,
          height: 600,
          child: GoogleMap(
            initialCameraPosition: position,
            mapType: MapType.normal,
            onMapCreated: (controller) {
              setState(() {
                _controller = controller;
              });
            },
            onTap: (cordinate) {
              _controller.animateCamera(CameraUpdate.newLatLng(cordinate));
              print(cordinate);
              test = cordinate as int;
            },
          ),
        ),
        Text(test.toString()),

有人知道错误是什么吗?

【问题讨论】:

    标签: google-maps flutter dart google-maps-api-2


    【解决方案1】:

    由于coordinateLAtLng,我认为您应该像这样更改测试:

    String test='';
    

    然后在你的 onTap 中:

    test = '${cordinate.latitude} - ${cordinate.longitude}';
    

    【讨论】:

      猜你喜欢
      • 2013-05-15
      • 1970-01-01
      • 1970-01-01
      • 2011-09-29
      • 2020-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多