地图显示时没有建筑物

时间:2017-07-24 12:14:57

标签: react-native mapbox mapbox-gl-js mapbox-gl

我正在寻找使用github / mapbox / react-native-mapbox-gl

在React-Native应用中渲染3D建筑物的方法

我在MapBox Studio中创建了一个自定义地图,将以下行添加到style.json中并在Mapbox Studio中上传了地图

{
    "id": "buildings",
    "type": "fill-extrusion",
    "source": "composite",
    "source-layer": "building",
    "minzoom": 15,
    "filter": [
        "all",
        [
            "==",
            "extrude",
            "true"
        ],
        [
            ">",
            "height",
            1
        ]
    ],
    "paint": {
        "fill-extrusion-color": "hsl(206, 7%, 61%)",
        "fill-extrusion-height": {
            "type": "identity",
            "property": "height"
        },
        "fill-extrusion-base": {
            "type": "identity",
            "property": "min_height"
        },
        "fill-extrusion-opacity": 1,
        "fill-extrusion-translate-anchor": "viewport"
    }
}

建筑物在mapbox-studio中按预期渲染,但当我回到我的React-Native App时,地图会显示但没有建筑物。

你们有没有想过如何用react-native-mapbox-gl sdk在3D中显示建筑物?

感谢。

Screenshot of mapbox studio Screenshot of the React-Native Map

1 个答案:

答案 0 :(得分:0)

此问题的兼容性修补程序:

  1. Mapbox Studio

    中为自定义地图添加新图层
    • 来源:Mapbox Streets V7(建筑物)
    • 类型:填充挤出
  2. 编辑样式 点击高度,然后编辑JSON(在面板底部)

Edit JSON information

然后,粘贴以下代码:

{
  "type": "identity",
  "property": "height"
}
  1. 粘贴并发布您的样式,并在React-Native中将其用作MapBox样式