简体   繁体   English

如何在 kepler.gl react.js 中切换图层可见性?

[英]How to toggle layer visibilty in kepler.gl react.js?

I have added a layer in my React app with kepler.gl.我使用 kepler.gl 在我的 React 应用程序中添加了一个层。

But the visibility of the layer is turned off.但是图层的可见性被关闭。 I can manually toggle the visibility in the map but not able to do so using React.我可以手动切换 map 中的可见性,但无法使用 React 这样做。

在此处输入图像描述

This is my config which I am passing in addDataToMap :这是我在addDataToMap中传递的配置:

    visState: {
        layerBlending: "normal",
        layers: [{
            id: "hty62yd",
            type: "point",
            config: {
                dataId: "dataset1",
                label: "label1",
                color: [
                    192,
                    192,
                    23
                ],
                columns: {
                    lat: "lat",
                    lng: "lon"
                }
            },
            isVisible: true,
            radius: 80
        }]
    }
};

The isVisible parameter was in wrong place. isVisible参数放置在错误的位置。

Correct config is:正确的配置是:

config: {
            dataId: "dataset1",
            label: "dataset1",
            color: [
                192,
                192,
                23
            ],
            columns: {
                lat: "lat",
                lng: "lon",
                altitude: ""
            },
            isVisible: true
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM