我尝试使用Mapbox在地图上添加图像。我点击了这个链接:https://docs.mapbox.com/ios/maps/examples/image-source/
当图片大小大于2048*2048时,图片为黑色,如下所示:

图像通常应如下所示:

如何让图片不会无限制地出现在黑色中?
发布于 2019-04-30 21:42:51
您似乎遇到了iOS Maps SDK的一个已知问题:https://github.com/mapbox/mapbox-gl-native/issues/12989。
一种可能的解决方法是将地理参考图像上传到您的Mapbox帐户,然后在运行时将其作为MGLRasterStyleLayer添加到地图中。您可以在此处看到此方法的示例:https://docs.mapbox.com/ios/maps/examples/image-source/
编辑:有关建议的解决方法的更多详细信息
Mapbox的iOS Maps SDK允许您在运行时应用栅格分片。您也可以使用upload geo-referenced images (a.k.a. GeoTiffs) to your Mapbox account,Mapbox会将其转换为栅格切片集,并为您提供一个“地图ID”,允许您从Mapbox的API中检索此切片集。映射ID如下所示:riastrad.1ckjd53j (即"username.unique_id")。
一旦有了地图ID,您就可以在运行时使用其中一个GL SDK将栅格切片集添加到任何地图。
在iOS上,样板代码如下所示:
import Mapbox
class RasterSourceExample: UIViewController, MGLMapViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
let mapView = MGLMapView(frame: view.bounds, styleURL: MGLStyle.darkStyleURL)
mapView.setCenter(CLLocationCoordinate2D(latitude: 43.457, longitude: -75.789), zoomLevel: 4, animated: false)
mapView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
mapView.tintColor = .darkGray
// Set the map view‘s delegate property.
mapView.delegate = self
view.addSubview(mapView)
}
func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle) {
// Create the raster tile source object
let source = MGLRasterTileSource(identifier: "tileset-source", configurationURL: URL(string: "mapbox://riastrad.1ckjd53j"))
style.addSource(source)
// Create a raster layer from the MGLRasterTileSource.
let rasterLayer = MGLRasterStyleLayer(identifier: "raster-layer", source: source)
style.addLayer(rasterLayer)
}
}⚠️免责声明:我目前在Mapbox⚠️工作
https://stackoverflow.com/questions/55921526
复制相似问题