如何禁用 kepler.gl 地图的侧面板?
How to disable side pannel of kepler.gl map?
我正在研究 kepler.gl
。我想禁用 kepler.gl
地图的侧面板。我不想向我的客户显示 kepler.gl
的侧面板。这是我在 kepler.gl
地图上显示数据的代码。在此代码中,我从 API 读取数据并将该数据显示到 kepler.gl
map?
import React from "react";
import keplerGlReducer from "kepler.gl/reducers";
import { createStore, combineReducers, applyMiddleware } from "redux";
import { taskMiddleware } from "react-palm/tasks";
import { Provider, useDispatch } from "react-redux";
import KeplerGl from "kepler.gl";
import { addDataToMap } from "kepler.gl/actions";
import useSwr from "swr";
const reducers = combineReducers({
keplerGl: keplerGlReducer
});
const store = createStore(reducers, {}, applyMiddleware(taskMiddleware));
export default function App() {
return (
<Provider store={store}>
<Map />
</Provider>
);
}
function Map() {
const dispatch = useDispatch();
const { data } = useSwr("covid", async () => {
const response = await fetch(
"https://gist.githubusercontent.com/leighhalliday/a994915d8050e90d413515e97babd3b3/raw/a3eaaadcc784168e3845a98931780bd60afb362f/covid19.json"
);
const data = await response.json();
return data;
});
console.log(data);
React.useEffect(() => {
if (data) {
dispatch(
addDataToMap({
datasets: {
info: {
label: "COVID-19",
id: "covid19"
},
data
},
option: {
centerMap: true,
readOnly: false
},
config: {}
})
);
}
}, [dispatch, data]);
return (
<KeplerGl
id="covid"
mapboxApiAccessToken="pk.eyJ1IjoiYWxpcmF6YTcwNSIsImEiOiJjazh5d2hjb3AwOHBqM2VsY21wOHo5eXprIn0.9G5CE4KqfbvU9HQ6WBuo3w"
width={window.innerWidth}
height={window.innerHeight}
/>
);
}
谁能帮我解决如何禁用 kepler.gl
地图的侧面板?
在addDataToMap方法中,你应该使用options而不是option,并且你应该设置readOnly: true
options: {
centerMap: true,
readOnly: true
}
我正在研究 kepler.gl
。我想禁用 kepler.gl
地图的侧面板。我不想向我的客户显示 kepler.gl
的侧面板。这是我在 kepler.gl
地图上显示数据的代码。在此代码中,我从 API 读取数据并将该数据显示到 kepler.gl
map?
import React from "react";
import keplerGlReducer from "kepler.gl/reducers";
import { createStore, combineReducers, applyMiddleware } from "redux";
import { taskMiddleware } from "react-palm/tasks";
import { Provider, useDispatch } from "react-redux";
import KeplerGl from "kepler.gl";
import { addDataToMap } from "kepler.gl/actions";
import useSwr from "swr";
const reducers = combineReducers({
keplerGl: keplerGlReducer
});
const store = createStore(reducers, {}, applyMiddleware(taskMiddleware));
export default function App() {
return (
<Provider store={store}>
<Map />
</Provider>
);
}
function Map() {
const dispatch = useDispatch();
const { data } = useSwr("covid", async () => {
const response = await fetch(
"https://gist.githubusercontent.com/leighhalliday/a994915d8050e90d413515e97babd3b3/raw/a3eaaadcc784168e3845a98931780bd60afb362f/covid19.json"
);
const data = await response.json();
return data;
});
console.log(data);
React.useEffect(() => {
if (data) {
dispatch(
addDataToMap({
datasets: {
info: {
label: "COVID-19",
id: "covid19"
},
data
},
option: {
centerMap: true,
readOnly: false
},
config: {}
})
);
}
}, [dispatch, data]);
return (
<KeplerGl
id="covid"
mapboxApiAccessToken="pk.eyJ1IjoiYWxpcmF6YTcwNSIsImEiOiJjazh5d2hjb3AwOHBqM2VsY21wOHo5eXprIn0.9G5CE4KqfbvU9HQ6WBuo3w"
width={window.innerWidth}
height={window.innerHeight}
/>
);
}
谁能帮我解决如何禁用 kepler.gl
地图的侧面板?
在addDataToMap方法中,你应该使用options而不是option,并且你应该设置readOnly: true
options: {
centerMap: true,
readOnly: true
}