mapbox / mapbox/mapbox-maps-ios
Polygon with a Border
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 601
- Forks
- 196
- PR merge metrics
- No merged PRs in 30d
Description
## 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the PolygonAnnotation and PolygonAnnotationGroup APIs, then compare their existing fillOutlineColor behavior with the PolylineAnnotation workaround described in the issue. Determine whether the requested border width, color, pattern, and inside/outside/center placement can be specified consistently, and verify the result with shared-edge polygons and SwiftUI rendering.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- mobile-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100