gpt4 book ai didi

ios - map 框 : Image is black if its size is greater than 2048 * 2048

转载 作者:行者123 更新时间:2023-11-28 13:41:50 24 4
gpt4 key购买 nike

我尝试使用 Mapbox 在 map 上添加图像。我点击了这个链接:https://docs.mapbox.com/ios/maps/examples/image-source/

如果图片尺寸大于2048*2048,图片显示为黑色,如下所示: enter image description here

图片通常应该是这样的: enter image description here

如何让图片不无限显示为黑色?

最佳答案

您似乎遇到了 iOS Maps SDK 的这个已知问题:https://github.com/mapbox/mapbox-gl-native/issues/12989 .

一种可能的解决方法是将地理引用图像上传到您的 Mapbox 帐户,然后在运行时将其作为 MGLRasterStyleLayer 添加到您的 map 。您可以在此处查看此方法的示例:https://docs.mapbox.com/ios/maps/examples/image-source/

编辑:有关建议解决方法的更多详细信息

Mapbox 的 iOS map SDK 允许您在运行时应用栅格图 block 。您也可以upload geo-referenced images (a.k.a. GeoTiffs) to your Mapbox account Mapbox 会将其转换为栅格图 block 集,并为您提供一个“ map ID”,使您可以从 Mapbox 的 API 中检索该图 block 集。 map ID 如下所示:riastrad.1ckjd53j(即“username.unique_id”)。

获得 map ID 后,您可以使用它在运行时使用其中一个 GL SDK 将栅格图 block 集添加到任何 map 。

在 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 工作 ⚠️

关于ios - map 框 : Image is black if its size is greater than 2048 * 2048,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55921526/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com