我正在尝试解决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) }
此选项参数不受支持吗?还是我做错了什么?
答案 0 :(得分:1)
发现问题不是将边界添加为NSValue,而是将其添加为MGLCoordinateBounds。