> For the complete documentation index, see [llms.txt](https://docs.mapbox.com/ios/maps/llms.txt)

# Add a polygon annotation

![Add a polygon annotation to the map.](https://docs.mapbox.com/ios/assets/ideal-img/maps-examples-polygon-annotation.25593e8.480.png)

This example demonstrates how to add a polygon annotation to a map using the [`PolygonAnnotation`](https://docs.mapbox.com/ios/maps/api/latest/documentation/mapboxmaps/polygonannotation/) and [`PolygonAnnotationManager`](https://docs.mapbox.com/ios/maps/api/latest/documentation/mapboxmaps/polygonannotationmanager/) classes in the **Mapbox Maps SDK for iOS**. The annotation includes customizable styling by setting [`fillColor`](https://docs.mapbox.com/ios/maps/api/latest/documentation/mapboxmaps/polygonannotation/fillcolor/) and [`fillOpacity`](https://docs.mapbox.com/ios/maps/api/latest/documentation/mapboxmaps/polygonannotation/fillopacity/) properties. It also demonstrates annotation interactivity by enabling the [`isDraggable`](https://docs.mapbox.com/ios/maps/api/latest/documentation/mapboxmaps/polygonannotation/isdraggable/) property and registering a [`tapHandler`](https://docs.mapbox.com/ios/maps/api/latest/documentation/mapboxmaps/polygonannotation/taphandler/).

> **Note: iOS Examples App Available**
> 
> This example code is part of the **Maps SDK for iOS Examples App**, a working iOS project [available on Github](https://github.com/mapbox/mapbox-maps-ios/tree/11.29.0/Sources/Examples). iOS developers are encouraged to run the examples app locally to interact with this example in an emulator and explore other features of the Maps SDK.
> 
> See our [Run the Maps SDK for iOS Examples App](https://docs.mapbox.com/help/tutorials/maps-sdk-ios-examples-app/) tutorial for step-by-step instructions.

**Swift**

Title: `PolygonAnnotationExample.swift`

[View on GitHub](https://github.com/mapbox/mapbox-maps-ios/blob/main/Sources/Examples/All%20Examples/Annotations/PolygonAnnotationExample.swift)

```swift
import MapboxMaps
import UIKit

final class ViewController: UIViewController {
    private var mapView: MapView!
    private var cancelables = Set<AnyCancelable>()

    override func viewDidLoad() {
        super.viewDidLoad()

        let centerCoordinate = CLLocationCoordinate2D(latitude: 25.04579, longitude: -88.90136)
        let options = MapInitOptions(cameraOptions: CameraOptions(center: centerCoordinate, zoom: 5.0))

        mapView = MapView(frame: view.bounds, mapInitOptions: options)
        mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        view.addSubview(mapView)

        // Allows the delegate to receive information about map events.
        mapView.mapboxMap.onMapLoaded.observeNext { _ in
            self.setupExample()

            
            
        }.store(in: &cancelables)
    }

    // Wait for the map to load before adding an annotation.
    private func setupExample() {

        // Create the PolygonAnnotationManager
        // Annotation managers are kept alive by `AnnotationOrchestrator`
        // (`mapView.annotations`) until you explicitly destroy them
        // by calling `mapView.annotations.removeAnnotationManager(withId:)`
        let polygonAnnotationManager = mapView.annotations.makePolygonAnnotationManager()

        // Create the polygon annotation
        var polygonAnnotation = PolygonAnnotation(polygon: makePolygon())

        // Style the polygon annotation
        polygonAnnotation.fillColor = StyleColor(.red)
        polygonAnnotation.fillOpacity = 0.8

        // Enable the polygon annotation to be dragged
        polygonAnnotation.isDraggable = true

        polygonAnnotation.tapHandler = { _ in
            print("polygon is tapped")
            return true
        }

        // Add the polygon annotation to the manager
        polygonAnnotationManager.annotations = [polygonAnnotation]
    }

    private func makePolygon() -> Polygon {

        // Describe the polygon's geometry
        let outerRingCoords = [
            CLLocationCoordinate2DMake(24.51713945052515, -89.857177734375),
            CLLocationCoordinate2DMake(24.51713945052515, -87.967529296875),
            CLLocationCoordinate2DMake(26.244156283890756, -87.967529296875),
            CLLocationCoordinate2DMake(26.244156283890756, -89.857177734375),
            CLLocationCoordinate2DMake(24.51713945052515, -89.857177734375)
        ]

        // This polygon has an intererior polygon which represents a hole in the shape.
        let innerRingCoords = [
            CLLocationCoordinate2DMake(25.085598897064752, -89.20898437499999),
            CLLocationCoordinate2DMake(25.085598897064752, -88.61572265625),
            CLLocationCoordinate2DMake(25.720735134412106, -88.61572265625),
            CLLocationCoordinate2DMake(25.720735134412106, -89.20898437499999),
            CLLocationCoordinate2DMake(25.085598897064752, -89.20898437499999)
        ]

        /// Create the Polygon with the outer ring and inner ring
        let outerRing = Ring(coordinates: outerRingCoords)
        let innerRing = Ring(coordinates: innerRingCoords)

        return Polygon(outerRing: outerRing, innerRings: [innerRing])
    }
}
```