New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Doc] Updated example for using react-map-gl Components with DeckGL #7129
Comments
Cool, Using the example in https://deck.gl/docs/api-reference/mapbox/mapbox-overlay#using-with-react-map-gl I was able to update my code to get it working as follows import { HexagonLayer } from '@deck.gl/aggregation-layers/typed';
import { MapboxOverlay, MapboxOverlayProps } from '@deck.gl/mapbox/typed';
import { Box } from 'grommet';
import {
Map,
ScaleControl,
FullscreenControl,
NavigationControl,
AttributionControl,
useControl,
} from 'react-map-gl';
import 'mapbox-gl/dist/mapbox-gl.css';
function DeckGLOverlay(props: MapboxOverlayProps) {
const overlay = useControl<MapboxOverlay>(() => new MapboxOverlay(props));
overlay.setProps(props);
return null;
}
// ...
export const MappyBoy = ({ shownLayers }: Props) => {
// ...
return(
<Box style={{ position: 'relative' }} fill>
<Map
attributionControl={false}
initialViewState={initialViewState}
mapStyle="mapbox://styles/mapbox/light-v10"
mapboxAccessToken=""
>
<DeckGLOverlay layers={shownLayers} />
<NavigationControl position="top-right" />
<FullscreenControl position="top-right" />
<AttributionControl position="bottom-right" />
<ScaleControl position="bottom-right" />
</Map>
</Box>
);
}; |
Hi @Pessimistress , your docs improvements in #7124 in are clearly welcome, especially the very clear sentence However, they contrast with the first paragraph of the page: As a result I was confused as to why the recommended (root deck mode) mode just didn't work for basic features like NavigationControl with recent versions of react-map-gl. Maybe you could also rework that section ? I see several possibilities
Additionally, maybe update the only example with controls (examples/get-started/react/mapbox/app.jsx )to use a more recent version than These are just ideas and suggestions, feel free to only pick up the ones you like. Of course, thanks a lot for your time and involvment in this awesome project and sharing it with the open source world PS: also commenting here since google results for this page come out first before the official docs and hopefully this clarifies some things for people |
@jonenst Using DeckGL as the root element supports all the features of deck.gl, not the features of react-map-gl or mapbox-gl. The limitations of MapboxOverlay are listed on its own documentation page. I am open to suggestions for improving the docs. Please open a new issue as we do not actively monitor closed issues and PRs. |
@Pessimistress Sure, thanks |
Link
https://deck.gl/docs/whats-new#use-react-map-gl-components-with-deckgl
Description
Hey guys,
I am trying to use the
react-map-gl
controls (e.g.FullScreenControl
) with aDeckGL
component in React-TypeScript land.The documentation makes reference to
MapContext
inreact-map-gl
, however this has since been changed out foruseMap()
anduseControl()
hooks as documented here, and as pointed out in this previous issue #6285 (comment) .Here is what it looks like without using a DeckGL solution and just using react-map-gl components inside of DeckGL -
As you can see, there is a component in the DOM that covers the controls on the top-right.
This means these controls are not interactive.
Here is that code which clearly does not have working controls -
Can we get an updated example of how to make these controls work?
The text was updated successfully, but these errors were encountered: