首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Mapbox :大于2048 * 2048的图片为黑色

Mapbox :大于2048 * 2048的图片为黑色
EN

Stack Overflow用户
提问于 2019-04-30 21:02:09
回答 1查看 265关注 0票数 0

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

当图片大小大于2048*2048时,图片为黑色,如下所示:

图像通常应如下所示:

如何让图片不会无限制地出现在黑色中?

EN

回答 1

Stack Overflow用户

发布于 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上,样板代码如下所示:

代码语言:javascript
复制
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⚠️工作

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55921526

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档