'MapAnnotation, how can we decide the zIndex of an Annotation?

when using the MapKit.Map to display multiple Annotation overlapping, everything works properly whether you use MapPin, MapMarker or MapAnnotation.

The tricky part is to bring an annotation to the front once you clickOnAnnotation. Considering MapPin, MapMarker or MapAnnotation are MapAnnotationProtocol Custom Types, which respectively, defined as follow in apple documentation:

// Available when SwiftUI is imported with MapKit
@available...
public protocol MapAnnotationProtocol {}

@available...
public struct MapMarker : MapAnnotationProtocol {
    public init(coordinate: CLLocationCoordinate2D, tint: Color? = nil)
}

// Available when SwiftUI is imported with MapKit
@available...
public struct MapPin : MapAnnotationProtocol {
    public init(coordinate: CLLocationCoordinate2D, tint: Color? = nil)
}

// Available when SwiftUI is imported with MapKit
@available...
public struct MapAnnotation<Content> : MapAnnotationProtocol where Content : View {
    public init(coordinate: CLLocationCoordinate2D, anchorPoint: CGPoint = CGPoint(x: 0.5, y: 0.5), @ViewBuilder content: () -> Content)
}

How can we implement a CustomView which also implements this protocol but provides us also with the needed properties which allows us to access the cooler feature of The Map (like zIndex as a start)?

I know we can still use UIViewRepresentable but that is not my goal, unless ...

helpfull Links:



Solution 1:[1]

After creating a TSI (Technical Support Incident) we got the following:

We have reviewed your request and have concluded that there is no supported way to achieve the desired functionality given the currently shipping system configurations.

suggestion was submitted to feedback assistant.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mohamed Aymen Haddad