fill-extrusion与mapbox-gl-js无法正确显示

问题描述 投票:1回答:1

这就是我的数据集的样子:

Seattle Crime Dataset

我想要做的是根据频率列更改挤出高度。我可以成功地显示这些作为点,但每当我使用填充挤出时我都在努力。你能指点我正确的方向吗?

    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'
    }
});
mapbox-gl-js
1个回答
2
投票

由于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);
  })

[Qazxswpoi]

© www.soinside.com 2019 - 2024. All rights reserved.