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

# Map recorder

Your browser doesn't support HTML5 video. Open [link to the video](https://docs.mapbox.com/ios/ios/assets/medias/MapRecorder-fd9be85a408b51b52fd6fb90e4d6889c.mp4).

This example demonstrates the [`MapRecorder`](https://docs.mapbox.com/ios/maps/api/latest/documentation/mapboxmaps/maprecorder/) feature in the **Mapbox Maps SDK for iOS**. In this implementation, when the map's style is loaded, a `MapRecorder` instance is created using `mapView.mapboxMap.makeRecorder()` and the recording is started. A camera animation is then initiated, flying to a specific location defined by [`CameraOptions`](https://docs.mapbox.com/ios/maps/api/latest/documentation/mapboxmaps/cameraoptions/). After the camera animation completes, the map recording is stopped, and the recorded sequence is replayed twice at double speed using the `replay` method with [`MapPlayerOptions`](https://docs.mapbox.com/ios/maps/api/latest/documentation/mapboxmaps/mapplayeroptions/) to customize playback settings. Additionally, the `playbackState` method is called to print the playback state of the recorder.

> **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: `MapRecorderExample.swift`

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

```swift
import UIKit
@_spi(Experimental) import MapboxMaps

final class ViewController: UIViewController {

    private var mapView: MapView!
    private var cancelables = Set<AnyCancelable>()

    override func viewDidLoad() {
        super.viewDidLoad()

        mapView = MapView(frame: view.bounds)
        mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        mapView.ornaments.options.scaleBar.visibility = .visible

        view.addSubview(mapView)

        mapView.mapboxMap.onStyleLoaded.observeNext { _ in
            // Once the Style is loaded, create the ``MapRecorder`` and start the recording
            guard let recorder = try? self.mapView.mapboxMap.makeRecorder() else { return }
            recorder.start()

            // Build a new set of CameraOptions for the map to fly to
            let cameraOptions = CameraOptions(center: CLLocationCoordinate2D(latitude: 45.4588, longitude: -73.581), zoom: 11, pitch: 35)

            self.mapView.camera.fly(to: cameraOptions, duration: 10, completion: { _ in
                // When the camera animation is complete, stop the map recording
                // Replay the camera animation twice at double speed by passing the recorded sequence returned from the stop method
                let mapRecordingSequence = recorder.stop()
                recorder.replay(recordedSequence: mapRecordingSequence, options: MapPlayerOptions(playbackCount: 2, playbackSpeedMultiplier: 2.0, avoidPlaybackPauses: false)) {
                    print(recorder.playbackState())
                }
            })
        }.store(in: &cancelables)
    }

    
}
```