地图框 iOS SDK 动态样式坐标边界崩溃



我正在尝试解决 Mapbox 示例中的水彩栅格图层示例,并根据文档添加额外的边界框参数。该应用程序总是因NSException而崩溃,并且没有进一步的见解。

func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle) {
let bounds = MGLCoordinateBounds(sw: CLLocationCoordinate2D(latitude: -180, longitude: -85.05112877980659), ne: CLLocationCoordinate2D(latitude: 180, longitude: 85.0511287798066))
let source = MGLRasterTileSource(identifier: "stamen-watercolor", tileURLTemplates: ["https://stamen-tiles.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.jpg"], options: [ .tileSize: 256, .coordinateBounds: bounds])
let rasterLayer = MGLRasterStyleLayer(identifier: "stamen-watercolor", source: source)
style.addSource(source)
style.addLayer(rasterLayer) }

此选项参数是否不受支持?还是我做错了什么?

发现问题不是将边界添加为 NSValue,而只是将它们添加为 MGLCoordinateBounds。

最新更新