Hello,
I have a React 17 app utilizing 4.21 of the JS Maps SDK. I am able to add the BasemapGallery widget with two basemaps, but the basemap tiles are duplicated 14 times. Is there a hook I should be using to prevent the duplication?
Also, how can I force the gallery to display as 3 horizontal tiles per row, instead of just vertically?
Thanks!!
const BasemapGroup = ({
label,
}: {
label: string;
children?: React.ReactNode;
}) => {
const mapComponents = useContext(MapContext);
const [open, setOpen] = useState(false);
const classes = useStyles();
const basemapGallery = new BasemapGallery({
view: mapComponents.view,
source: [Basemap.fromId("hybrid"), Basemap.fromId("gray")],
});
return (
<Box mb={5} className={classes.layerGroupContainer}>
<MetricLabelLight
style={{ color: palette.blue, cursor: "pointer" }}
onClick={() => {
setOpen(!open);
}}
>
{label}
</MetricLabelLight>
<Collapse in={true} timeout={500}>
<div
ref={(element) => element && (basemapGallery.container = element)}
></div>
</Collapse>
</Box>
);
};
...
<BasemapGroup label="Basemaps" key="Basemaps"></BasemapGroup>