Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/383.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 属性“圆颜色”始终绘制黑色圆_Javascript_Reactjs_Mapbox_Geojson - Fatal编程技术网

Javascript 属性“圆颜色”始终绘制黑色圆

Javascript 属性“圆颜色”始终绘制黑色圆,javascript,reactjs,mapbox,geojson,Javascript,Reactjs,Mapbox,Geojson,我试图在mapbox gl地图上显示多个圆。圆圈的颜色取决于aqi属性的值。我已经根据该值设置了颜色的插值。问题是我总是有黑眼圈 圆形颜色属性: 'circle-color': [ 'interpolate', ['linear'], ['get', 'aqi'], 0, '#eee695', 50, '#a5fc03', 100, '#dbfc03', 200, '#fc1c03'

我试图在mapbox gl地图上显示多个圆。圆圈的颜色取决于
aqi
属性的值。我已经根据该值设置了颜色的插值。问题是我总是有黑眼圈

圆形颜色属性:

'circle-color': [
    'interpolate',
    ['linear'],
    ['get', 'aqi'],
    0,        
    '#eee695',
    50,
    '#a5fc03',
    100,     
    '#dbfc03',
    200,
    '#fc1c03'  
],
全部功能:

 map.on('load', () => {
                Axios.get('https://api.waqi.info/map/bounds/?latlng=41.03143,20.52421,42.20194,22.89056&token='+AQI_KEY).then(res=>{
                    const data = [];
                    res.data.data.map(station=>{
                        if(station.aqi!=='-'){
                            data.push(JSON.stringify({ "type": "Feature", "properties": {"aqi": station.aqi},
                            "geometry":
                            {
                                "type": "Point", "coordinates": [ station.lon, station.lat ]
                            }
                            }))
                        }
                    })
                    map.addSource('AQI', {
                        'type': 'geojson',
                        'data':
                        {
                            "type": "FeatureCollection",
                            "crs": { "type": "name", "properties": { "aqi": "aqi" } },
                            "features": data.map(JSON.parse)
                        }
                        });
                        map.addLayer(
                            {
                            'id': 'AQI-heat',
                            'type': 'circle',
                            'source': 'AQI',
                            'paint': {
                                'circle-radius': {
                                    'type': 'exponential',
                                    'stops': [[0, 70], [500, 70]]
                                },
                                'circle-opacity': {
                                    'type': 'exponential',
                                    'stops': [[-99, 0.0], [-50, 1.0]]
                                },
                                'circle-color': [
                                    'interpolate',
                                    ['linear'],
                                    ['get', 'aqi'],
                                    0,        
                                    '#eee695',
                                    50,
                                    '#a5fc03',
                                    100,     
                                    '#dbfc03',
                                    200,
                                    '#fc1c03'

                                ],
                                'circle-blur': 1
                
                            }
                            }
                        );
                })
        })
    }
即使我为不同的值设置了不同的颜色,我总是得到黑色的圆圈