leaflet - 将 terrain-rgb 层添加到 MaboxGL.js?

标签 leaflet mapbox-gl-js

我想使用 Mapbox 的 terrain-rgb 瓦片作为 Mapbox GL map 中的图层。 我看到的操作 terrain-rgb 数据的示例使用 L.tileLayer 为新层构建图 block : https://www.mapbox.com/blog/terrain-rgb/

使用 MapboxGL.js,我尝试以这种方式添加图层:

    map.on('load', function () {

      map.addSource('terrain-rgb', {
          type: 'vector',
          url: 'https://api.mapbox.com/v4/mapbox.terrain-rgb/{z}/{x}/{y}.pngraw?access_token=pk.eyJ1IjoibWF0dCIsImEiOiJTUHZkajU0In0.oB-OGTMFtpkga8vC48HjIg'
      });
      map.addLayer({
          'id': 'terrain-rgb',
          'type': 'fill',
          'source': 'terrain-rgb',
          'layout': {
              'visibility': 'visible'
          },
          'paint': {
             'fill-color': 'rgba(15,148,179,.4)'
          },
          'source-layer': 'terrain-rgb'
      });

    });

我尝试了填充、线条和圆形类型,但它们不起作用。 我收到这些控制台错误:

GET https://api.mapbox.com/v4/mapbox.terrain-rgb/%7Bz%7D/%7Bx%7D/%7By%7D.pngraw…ss_token=pk.eyJ1IjoibWF0dCIsImEiOiJTUHZkajU0In0.oB-OGTMFtpkga8vC48HjIg 404 (Not Found)  ajax.js:25 

Object {type: "error", target: t, isSourceLoaded: false, source: Object, sourceId: "terrain-rgb"}   evented.js:104 

如何正确地将 terrain-rgb 源添加到 mapboxgl.js?

最佳答案

好的,看了github上的issues,好像还不能这样: https://github.com/mapbox/mapbox-gl-js/issues/3730

关于leaflet - 将 terrain-rgb 层添加到 MaboxGL.js?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43289845/

相关文章:

onclick - 单击更改(和更改回)传单图标

javascript - 将数据对象传递给触发事件

mapbox-gl-js - Mapbox GL JS 中的 eventData 参数是什么?

javascript - 如何在leaflet实时js api中使用推送模型

reactjs - 如何在我的事件处理程序中访问 React 状态?

postgresql - Postgis - ST_within 没有做我想做的事。如何在空心区域中找到一个点?

javascript - mapbox-gl 支持 MultiLineString geoJSON 要素类型吗?

mapbox - Mapbox GL JS V2 中 3D 地形的自定义 DEM

javascript - 如何在 React.js 中编写以下 Mapbox map 层?

javascript - 通过 include() 更改 Leaflet 类的行为