如何在Flutter中为Google Maps设置Map onClick侦听器?

时间:2020-02-29 16:16:48

标签: google-maps flutter google-maps-markers

我想在用户在我的Google Maps Flutter应用程序中单击的纬度和经度上放置一个标记。到目前为止,我发现的所有内容都是JavaScript或谈论点击标记。我需要在地图上的任意位置拦截点击,并能够查看其地理位置。这可能吗?

1 个答案:

答案 0 :(得分:2)

GoogleMap为您提供了onTap回调,为您提供了LatLng

GoogleMap(
  onTap: (LatLng latLng) {
    // you have latitude and longitude here 
    var latitude = latLng.latitude;
    var longitude = latLng.longitude;
  },
);