【问题标题】:Flutter: Update the position of markerFlutter:更新标记的位置
【发布时间】:2021-08-31 06:59:36
【问题描述】:

如何在 Google 地图中更新标记的位置?用什么方法来更新它?我正在使用 API 数据。

【问题讨论】:

  • 我找到了解决办法,我用了Timer

标签: flutter google-maps


【解决方案1】:

更新来自 api 数据的新 Latlang 上的标记位置。如此简单 制作标记并根据latlang显示标记。

    function changeMarkerPosition(marker) {
        var latlng = new google.maps.LatLng(40.748774, -73.985763);
        marker.setPosition(latlng);
    }

【讨论】:

    【解决方案2】:

    获取新的latlng后添加新的标记

    setState(() {
    _markers.add(Marker(
        markerId: MarkerId('marker_Id'),
        position: UPDATED_LAT_LNG,
        icon: sourceIcon));)}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-26
      • 2012-01-28
      • 2015-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-30
      相关资源
      最近更新 更多