Polygon with a Border
New Feature
Can I get an easier way to draw a PolygonAnnotation with a Border in SwiftUI? Currently, I have to add a Polygon and a Polyline. It would be awesome if I could do something like:
PolygonAnnotationGroup(areas) { area in
let areaType = area.properties.type
return PolygonAnnotation(polygon: area.mbPolygon)
.fillColor(areaType.uiColor)
.fillOpacity(0.1)
.borderWidth(1.5)
.borderColor(.red)
.borderPattern("MyPatternName")
.borderPlacing(.inside) // or .outside or .center
}
}
Especially the last one is important for me: .borderPlacing() (in combination with the width).
(or you can use stroke, or outline, fillOutline, etc in stead of 'border')
Why
I need a border that renders just inside the polygon.
Currently, I work around this by creating both a PolygonAnnotation and a matching PolylineAnnotation using the same coordinates. However, the polyline border is drawn centered on the polygon edge — half inside, half outside. This doesn't meet my design needs, as I require the border to be entirely within the polygon.
This workaround also adds performance overhead: every visual area results in two annotations instead of one, likely reducing rendering efficiency and responsiveness.
The built-in fillOutlineColor on PolygonAnnotation appears to draw a fixed 1-pixel stroke centered on the polygon edge. This causes overlapping borders when polygons share edges, just like my own solution, which blends colors of neighboring area's and makes it impossible to use border color as a clear identifier for each polygon.
For my use case — where border color indicates the type of airspace — this is undesirable. I need either: • Control over the border width and position (e.g. .inside, .outside, .centered), or • A way to render the border fully inside the polygon. This would avoid overlaps and preserve visual clarity, allowing border color to communicate meaning reliably.