Stylesheet contains a source with identifier "aerial". Asking for the source from style
results in a crash.
mapView.on(.styleLoadingFinished) { [weak self] event in
let result = self.mapView.style.getSource(identifier: "aerial", type: RasterSource.self) // CRASH
...
}
Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=com.mapbox.bindgen Code=-2 "*** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: bounds)" UserInfo={NSUnderlyingErrorKey=*** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: bounds), NSLocalizedFailureReason=*** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: bounds)}: file MapboxMaps/Style.swift, line 271
func handle<T>(result: Result<T, SourceError>) {
switch result {
case .success(let source):
log("source is \(source)")
case .failure(let error):
log("getSource failed: \(error)")
}
}
let identifier: String = "com.mapbox.AnnotationManager.DefaultSourceLayer"
handle(result: style.getSource(identifier: identifier, type: VectorSource.self))
handle(result: style.getSource(identifier: identifier, type: RasterSource.self))
handle(result: style.getSource(identifier: identifier, type: RasterDemSource.self))
handle(result: style.getSource(identifier: identifier, type: GeoJSONSource.self))
handle(result: style.getSource(identifier: identifier, type: ImageSource.self))
handle(result: style.getSource(identifier: identifier, type: ModelSource.self))
[style] source is VectorSource(type: MapboxMaps.SourceType.geoJson, url: nil, tiles: nil, bounds: nil, scheme: nil, minzoom: nil, maxzoom: nil, attribution: nil, volatile: nil, prefetchZoomDelta: nil, minimumTileUpdateInterval: nil, maxOverscaleFactorForParentTiles: nil)
[style] source is RasterSource(type: MapboxMaps.SourceType.geoJson, url: nil, tiles: nil, bounds: nil, minzoom: nil, maxzoom: nil, tileSize: nil, scheme: nil, attribution: nil, volatile: nil, prefetchZoomDelta: nil, minimumTileUpdateInterval: nil, maxOverscaleFactorForParentTiles: nil)
[style] source is RasterDemSource(type: MapboxMaps.SourceType.geoJson, url: nil, tiles: nil, bounds: nil, minzoom: nil, maxzoom: nil, tileSize: nil, attribution: nil, encoding: nil, volatile: nil, prefetchZoomDelta: nil, minimumTileUpdateInterval: nil, maxOverscaleFactorForParentTiles: nil)
[style] source is GeoJSONSource(type: MapboxMaps.SourceType.geoJson, data: nil, maxzoom: nil, attribution: nil, buffer: nil, tolerance: nil, cluster: nil, clusterRadius: nil, clusterMaxZoom: nil, clusterProperties: nil, lineMetrics: nil, prefetchZoomDelta: nil)
[style] source is ImageSource(type: MapboxMaps.SourceType.geoJson, url: nil, coordinates: nil, prefetchZoomDelta: nil)
[style] source is ModelSource(type: MapboxMaps.SourceType.geoJson, models: nil)
No crash in the first case. A GeoJsonSource
in the latter case.