Hello,
I'm working on a SwiftUI/MapKit project. It uses a custom annotation to mark zip codes on the map. I have an onTapGesture configured to run a custom function when the user clicks on the RoundedRectangle content included in the Annotation.
I'm using the .annotationTitles(.hidden)
modifier on the Annotation so that the title is not shown below my custom annotation. However, when I click below my annotation (where the hidden title text would be) the normal MapKit selection behavior executes. My project has Markers on the map in which I do want this behavior. It pulls up a half sheet detail view for the Marker. It does not make sense for this half sheet detail view to be displayed when tapping on a zip code.
I tried using a ZStack with a transparent rectangle offset to drop below my annotation (yellow in screenshot), and included the same onTapGesture with custom function for this. My hope was that the transparent (yellow) RoundedRectangle would override the behavior of clicking on the hidden title. This didn't work.
Any ideas? Thanks for your help!