dosubot[bot] commented on issue #30059:
URL: https://github.com/apache/superset/issues/30059#issuecomment-2318931789
<!-- Greeting -->
Hey there, @pesekon2! I'm here to help you with any issues you're
experiencing. I can assist with bug fixes, answer your questions, and guide you
on becoming a contributor.
<!-- Answer -->
The blank background issue in map charts in Superset 4.0.2, despite
providing the `MAPBOX_API_KEY` in `docker/.env` and validating the token, could
be due to the `mapStyle` prop not being set correctly. The `mapStyle` prop is
used to define the style of the map, and if it is not set or is set
incorrectly, the map may not render properly.
In the `transformProps` function of the `MapBox` plugin, the `mapStyle` is
derived from the `formData`:
```js
const {
clusteringRadius,
globalOpacity,
mapboxColor,
mapboxStyle,
pandasAggfunc,
pointRadius,
pointRadiusUnit,
renderWhileDragging,
} = formData;
```
Ensure that the `mapboxStyle` in your form data is correctly set to a valid
Mapbox style URL. For example:
```js
const mapboxStyle = 'mapbox://styles/mapbox/streets-v11';
```
If the `mapboxStyle` is not provided or is incorrect, the map will not
render, resulting in a blank background. Additionally, make sure that other
required properties such as `mapboxApiKey` are correctly passed and validated
in the `transformProps` function.
Furthermore, ensure that the `mapboxStyle` is validated using the
`validateMapboxStylesUrl` function, as shown in the shared control
configurations for the DeckGL viz plugin:
```js
export const mapboxStyle = {
name: 'mapbox_style',
config: {
type: 'SelectControl',
label: t('Map Style'),
clearable: false,
renderTrigger: true,
freeForm: true,
validators: [validateMapboxStylesUrl],
choices: [
['mapbox://styles/mapbox/streets-v9', t('Streets')],
['mapbox://styles/mapbox/dark-v9', t('Dark')],
['mapbox://styles/mapbox/light-v9', t('Light')],
['mapbox://styles/mapbox/satellite-streets-v9', t('Satellite
Streets')],
['mapbox://styles/mapbox/satellite-v9', t('Satellite')],
['mapbox://styles/mapbox/outdoors-v9', t('Outdoors')],
],
default: 'mapbox://styles/mapbox/light-v9',
description: t(
'Base layer map style. See Mapbox documentation: %s',
'https://docs.mapbox.com/help/glossary/style-url/',
),
},
};
```
By ensuring the `mapboxStyle` is correctly set and validated, you can
resolve the blank background issue in your map charts
<sup>[[1]](https://github.com/apache/superset/blob/master/superset-frontend/plugins/legacy-plugin-chart-map-box/src/MapBox.jsx)</sup><sup>[[2]](https://github.com/apache/superset/blob/master/superset-frontend/plugins/legacy-plugin-chart-map-box/src/transformProps.js)</sup><sup>[[3]](https://github.com/apache/superset/blob/master/superset-frontend/plugins/legacy-preset-chart-deckgl/src/utilities/Shared_DeckGL.jsx)</sup>.
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]