How to add a marker tap/click on map using Flutter/Dart?
The plugin has finally added an onTap
property for the GoogleMap
Class.
final ArgumentCallback<LatLng> onTap
Example:
GoogleMap(
markers: _markers,
initialCameraPosition: _theSecretLocation,
onMapCreated: (GoogleMapController controller) {
_controller.complete(controller);
},
onTap: _handleTap,
),
...
_handleTap(LatLng point) {
setState(() {
_markers.add(Marker(
markerId: MarkerId(point.toString()),
position: point,
infoWindow: InfoWindow(
title: 'I am a marker',
),
icon:
BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueMagenta),
));
});
}