keplergl / kepler.gl

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
http://kepler.gl
MIT License
10.12k stars 1.71k forks source link

onClick not work #2505

Closed SincerelyUnique closed 5 months ago

SincerelyUnique commented 6 months ago

Describe the bug Hi Team, sorry to bother you, when I set onClick to KeplerGl, it doesn't works, could you please help to check on it?

To Reproduce Steps to reproduce the behavior:

  1. load kepler
  2. Add data & config
  3. Export map
  4. Click the map
  5. console.log not output

Expected behavior Want to get the console.log

Screenshots F12 no console log

Environment (please complete the following information):

Additional context

function App() {
  const [sampleTripData, setSampleTripData] = useState();
  const dispatch = useDispatch();

  const fetchData = async () => {
    setSampleTripData(processGeojson(sampleGeojsonPoints));
  };

  useEffect(() => {
    fetchData();
  }, []);

  useEffect(() => {
    sampleTripData &&
      dispatch(
        addDataToMap({
          datasets: [
            {
              info: {
                label: 'Latency',
                id: 'bart-stops-geo'
              },
              data: sampleTripData
            }
          ],
          options: {
            keepExistingConfig: true
          },
          config: sampleGeojsonConfig
        })
      );
  }, [dispatch, sampleTripData]);

  const handleMapClick = (info, event) => {
    // here is the question , when I click the map , no output here
    console.log('Map Clicked!', info, event);
  };

  return (
    <KeplerGl
      id="map"
      width={window.innerWidth}
      mapboxApiAccessToken="***"
      height={window.innerHeight}
      onClick={handleMapClick}
    />
  );
}
SincerelyUnique commented 5 months ago

ref to https://github.com/keplergl/kepler.gl/issues/1464 and solved