How do I set a Map onClick listener for Google Maps in Flutter?

Viewed 3125

I want to place a marker at the latitude and longitude that the user clicks on in my Google Maps Flutter application. Everything I have found so far has been JavaScript or talking about marker on clicks. I need to intercept a click at any point on the map and be able to see its geolocation. Is this possible?

1 Answers

GoogleMap provides you onTap callback which gives you LatLng.

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