On flutter_map I add a custom marker in marker layer. Wrap the builder of the marker widget with a gesturedetector expecting detect a tap over the marker. Did not detect nothing
The flutter map is in stack widget and the onTap option of flutter_map MapOptions works fine.
return Scaffold(
body: Container(
child:
FlutterMap(
options: MapOptions(
center: LatLng(_currentPosition!.latitude, _currentPosition!.longitude),
zoom: 15,
interactiveFlags: InteractiveFlag.all,
),
mapController: _mapController,
children: [
TileLayer(
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
userAgentPackageName: 'com.example.app',
),
MarkerLayer(
markers: [
Marker(
point: LatLng(_currentPosition!.latitude, _currentPosition!.longitude),
width: 35,
height: 35,
builder: (context) => GestureDetector(
onTap: () {
print("tap on start");
},
child:IgnorePointer(
child: Container(
decoration: const BoxDecoration(
color: Color.fromARGB(255, 3, 101, 6),
shape:BoxShape.circle,
),
child: const Icon(
color: Colors.white,
Icons.pin_drop_rounded,
),
),
),
)
)
]
),
//MapsMarkerLayer(initialLocation: LatLng(_currentPosition!.latitude, _currentPosition!.longitude),markerPosition: deliveryMarkers),
mapsPolylines(jobId: widget.jobId)
],
),
),
);
Wrap your
Markerwith theIgnorePointerwidget, and then wrap theIgnorePointerwithGestureDetector.Learn more about it from this official tutorial. IgnorePointer class