keplergl / kepler.gl

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

Mapbox v2.0 3D terrain integration #1520

Open stefaniliskovic opened 3 years ago

stefaniliskovic commented 3 years ago

Is it possibile to use Mapbox 3D terrain in kepler as a map style ?

crnismrk commented 3 years ago

Pass a getMapboxRef callback to Kepler instance.

          <Kepler 
            id="foo"
            mapboxApiAccessToken={mapboxApiAccessToken}
            width={width}
            height={height}
            getMapboxRef={setMapboxRef}
          />

once you have access to mapbox ref you can add dem source and configure map to show 3D terrain

  useEffect(() => {
    if(mapboxRef) {
      const map = mapboxRef.getMap();
      map.on('load', () => {
        map.addSource("mapbox-dem", {
          type: "raster-dem",
          url: "mapbox://mapbox.mapbox-terrain-dem-v1",
          tileSize: 512,
          maxZoom: 16,
        });
        map.setTerrain({ source: "mapbox-dem", exaggeration });
      });
    }
  }, [mapboxRef])