To import a Mapbox map from CodePen into Webflow, you need to embed the correct HTML, CSS, and JavaScript, and ensure your Mapbox access token is valid and properly loaded. Here's how to do it and troubleshoot token issues.
mapboxgl.accessToken = '...'
).<div id="map"></div>
for the map container).Go to Page Settings or Project Settings > Custom Code.
Under Before
, paste the Mapbox JavaScript initialization code, making sure it includes:
Loading the Mapbox script (via <script src="...">
)
Valid accessToken
Map initialization logic
For example (do not copy raw into Webflow, just reference):
mapboxgl.accessToken = 'YOUR_TOKEN';
new mapboxgl.Map({ container: 'map', ... });
If your map does not display, the issue may be with the token:
To import a Mapbox map from CodePen into Webflow: copy the HTML/JS code from CodePen, embed it using Webflow’s Embed element, and ensure your Mapbox access token is valid and unrestricted. Token issues usually arise from expired keys or domain restrictions, which can be resolved in your Mapbox account settings.