简体   繁体   English

如何从数据库中向 Keplergl React 添加数据

[英]How to add data on keplergl React from database

I'm working with keplergl and I'd like to retrieve data from my database but kepler can't detect my data despite receiving an object in my console.我正在使用keplergl,我想从我的数据库中检索数据,但是尽管在我的控制台中收到了object,但kepler 无法检测到我的数据。

Receiving my object in my console在我的控制台中接收我的 object

What should I do?我应该怎么办? thank you in advance先感谢您

const reducers = combineReducers({
  keplerGl: keplerGlReducer
});

const store = createStore(reducers, {}, applyMiddleware(taskMiddleware));

export default function App() {
  return (
    <Provider store={store}>
      <Routes />
      <Map />
    </Provider>
  );
}

Fetch + json + map取 + json + map

function Map() {

  
  
  console.log("data", data)

configure parameters配置参数

  React.useEffect(() => {
    if (data) {
      dispatch(
        addDataToMap({
          datasets: {
            info: {
              label: "COVID-19",
              id: "covid19"
            },
            data:data
          },
          option: {
            centerMap: true,
            readOnly: false
          },
          config: {

          }
        })
      );
    }
  }, [dispatch, data]);

KeplerGl Component KeplerGl 组件

  return (
    
    <KeplerGl
      id="covid"
      mapboxApiAccessToken={process.env.REACT_APP_MAPBOX_API}
      width={window.innerWidth}
      height={window.innerHeight}
    />
    
  );
}

you can find a tutorial on how to dynamically update a dataset with new data here: http://vis.academy/#/kepler.gl/3-load-config您可以在此处找到有关如何使用新数据动态更新数据集的教程: http://vis.academy/#/kepler.gl/3-load-config

please see section "2. Replace an existing dataset with new data with the same format, keeping the current config."请参阅“2. 用相同格式的新数据替换现有数据集,保留当前配置”部分。

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

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