MapPolygon

I recently converted over my map from Mapbox Maps to MapKit Map. I have been able to add my polygons on the Map using MapPolygon. The issue I am having is being able to select the Polygon to be able to view information about the polygon.

Has anyone been able to figure out a way to tap on the Polygon? I have tried selection but the Polygon doesn't recognize the tap. I would really appreciate it if anyone could point me in the right direction of how I can accomplish this.

Pretty sure hit testing with a MapReader proxy is the way to go: Something like:

MapReader { proxy in
	Map(initialPosition: cameraPosition) {
		MapPolygon(polygon)
			.stroke(.purple.opacity(0.5), lineWidth: 5)
			.foregroundStyle(isSelected ? .purple.opacity(0.2) : .clear)
	}
	.onTapGesture { tapPoint in
		if let coordinate = proxy.convert(tapPoint, from: .local) {
			let renderer = MKPolygonRenderer(polygon: polygon)
			let mapPoint = MKMapPoint(coordinate)
			let rendererPoint = renderer.point(for: mapPoint)
			
			if renderer.path.contains(rendererPoint) {
				isSelected.toggle()
			}
		}
	}
}
MapPolygon
 
 
Q