I have integrated MapBox into my app, and am trying to create snapshots of the map with MGLMapSnapshotter. I have copied the function directly from the website. The style that options is drawing from shows up correctly on the map. Can anyone tell me why it is failing to create a snapshot?

func createSnapshot(completion: @escaping (UIImage?) -> Void) {
    // Use the map's style, camera, size, and zoom level to set the snapshot's options.
    let options = MGLMapSnapshotOptions(styleURL: tripPhotosMap.styleURL, camera: tripPhotosMap.camera, size: tripPhotosMap.bounds.size)
    options.zoomLevel = tripPhotosMap.zoomLevel

    // Create the map snapshot.
    var snapshotter: MGLMapSnapshotter? = MGLMapSnapshotter(options: options)
    snapshotter?.start { (snapshot, error) in
        if error != nil {
            print("Unable to create a map snapshot.")
            print(error?.localizedDescription)
            completion(nil)
        } else if let snapshot = snapshot {
            // Add the map snapshot's image to the image view.
            completion(snapshot.image)
        }
        snapshotter = nil
    }
}

Error

{com.mapbox.mbgl.Map Snapshotter}[Style]: Failed to load sprite: HTTP status code 404

0 Answers