填写挤压不mapbox-GL-JS正确显示(fill-extrusion not displayin

2019-09-26 06:30发布

这是我的数据集的样子:

西雅图犯罪数据集

我想要做的是改变基于频率柱拉伸高度。 我可以成功地显示这些为点,但我与它挣扎时,我用填充挤压。 你能帮点我朝着正确的方向?

    map.addLayer({
    'id': 'total',
    'type': 'circle',
    'source': {
        type: 'vector',
        url: 'mapbox://askakdagr8.9tklrr8g'
    },
    'source-layer': 'GroupedOutput-9i6ink',
    'paint': {
        // make circles larger as the user zooms from z12 to z22
        'circle-radius': {
            'base': 1.75,
            'stops': [
                [12, 2],
                [22, 180]
            ]
        },
        'circle-color': '#ff7770'
    }
});

Answer 1:

由于mapbox-gl-js目前不具备的功能用于挤出一个圈,你需要用一个多边形来代替点和内插圈,例如,通过一个函数turf.circle

  map.on('sourcedata', function(e) {
    if (e.sourceId !== 'total') return
    if (e.isSourceLoaded !== true) return

    var data = {
      "type": "FeatureCollection",
      "features": []
    }
    e.source.data.features.forEach(function(f) {
      var object = turf.centerOfMass(f)
      var center = object.geometry.coordinates
      var radius = 10;
      var options = {
        steps: 16,
        units: 'meters',
        properties: object.properties
      };
      data.features.push(turf.circle(center, radius, options))
    })
    map.getSource('extrusion').setData(data);
  })

[ http://jsfiddle.net/zjLek40n/ ]



文章来源: fill-extrusion not displaying correctly with mapbox-gl-js