platform_maps_flutter icon indicating copy to clipboard operation
platform_maps_flutter copied to clipboard

Map takes tap event when tap is performed on marker

Open anuroopsinghal07 opened this issue 4 years ago • 4 comments

Hello, I have added a feature to add pins on tap of map. Pin also displays info window when tap is performed on pin. When I tap on pin to open info window, map also adds new pin because map takes tap event. I could not find anything to fix it and looks like a defect.

anuroopsinghal07 avatar Feb 18 '21 10:02 anuroopsinghal07

I have a similar problem: when I tap on a marker onTap callback is triggered. The second time I tap on the same marker the onTap callback is NOT triggered.

dev4jam avatar Aug 22 '22 00:08 dev4jam

I have same issue @dev4jam. Have you found any solution?

Tapaniya25 avatar Sep 03 '22 06:09 Tapaniya25

I faced the same issue and found a very hacky workaround for it. I just append a random uuid to the marker id and call setState() when tapping the marker. E.g.

PlatformMap(
                initialCameraPosition: initialCamera,
                markers: locations.map(
                        (location) {
                          return Marker(
                            markerId:
                                MarkerId(location.locationId + uuid.v4()),
                            position: LatLng(
                              location.geoCoordinate.latitude,
                              location.geoCoordinate.longitude,
                            ),
                            consumeTapEvents: true,
                            onTap: () {
                              // handle tap logic
                              setState(() {});
                            },
                          );
                        },
                      ).toSet(),
                gestureRecognizers: const {
                  Factory<OneSequenceGestureRecognizer>(
                    EagerGestureRecognizer.new,
                  ),
                },
)

ChrisMarxDev avatar Jun 20 '23 12:06 ChrisMarxDev

We are still experiencing this issue. Any ideas?

SDAChess avatar Nov 08 '23 03:11 SDAChess