1 - import 'mapbox-gl/dist/mapbox-gl.css';

2 - override css class called .mapboxgl-canvas

.mapboxgl-canvas {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
}
Answer from Javier on Stack Overflow
🌐
React Map GL
visgl.github.io › get started
Get Started | react-map-gl
import * as React from 'react'; import Map from 'react-map-gl/maplibre'; import 'maplibre-gl/dist/maplibre-gl.css'; function App() { return ( <Map initialViewState={{ longitude: -122.4, latitude: 37.8, zoom: 14 }} style={{width: 600, height: 400}} mapStyle="https://api.maptiler.com/maps/streets/style.json?key=get_your_own_key" /> ); }
🌐
GitHub
github.com › visgl › react-map-gl › blob › master › docs › get-started › get-started.md
react-map-gl/docs/get-started/get-started.md at master · visgl/react-map-gl
import * as React from 'react'; import Map from 'react-map-gl/mapbox'; // If using with mapbox-gl v1: // import Map from 'react-map-gl/mapbox-legacy'; import 'mapbox-gl/dist/mapbox-gl.css'; function App() { return ( <Map mapboxAccessToken="<Mapbox access token>" initialViewState={{ longitude: -122.4, latitude: 37.8, zoom: 14 }} style={{width: 600, height: 400}} mapStyle="mapbox://styles/mapbox/streets-v9" /> ); }
Author   visgl
🌐
React Map GL
visgl.github.io › react-map-gl
Home | react-map-gl
Comes with additional React interfaces such as context and hooks to support custom components. Use together with e.g. deck.gl to render performant and compelling 2D and 3D WebGL visualizations on top of your MapLibre GL JS and Mapbox GL JS based maps.
🌐
React Map GL
visgl.github.io › what's new
What's new | react-map-gl
New Components: FullscreenControl, GeolocateControl have been added to provide better React parity with the Mapbox GL JS API. New callback props InteractiveMap supports more callbacks: ... Relative dimensions Both InteractiveMap and StaticMap now support CSS strings supplied to map width and height props.
🌐
GitHub
github.com › visgl › react-map-gl
GitHub - visgl/react-map-gl: React friendly API wrapper around MapboxGL JS · GitHub
react-map-gl is a suite of React components designed to provide a React API for mapbox-gl or maplibre-gl.
Starred by 8.4K users
Forked by 1.4K users
Languages   TypeScript 65.5% | JavaScript 32.2%
🌐
npm
npmjs.com › package › @urbica › react-map-gl
@urbica/react-map-gl - npm
July 19, 2022 - import React, { useState } from 'react'; import MapGL from '@urbica/react-map-gl'; import 'mapbox-gl/dist/mapbox-gl.css'; const [viewport, setViewport] = useState({ latitude: 37.78, longitude: -122.41, zoom: 11 }); <MapGL style={{ width: '100%', height: '400px' }} mapStyle='mapbox://styles/mapbox/light-v9' accessToken={MAPBOX_ACCESS_TOKEN} latitude={viewport.latitude} longitude={viewport.longitude} zoom={viewport.zoom} onViewportChange={setViewport} />; Sources specify the geographic features to be rendered on the map.
      » npm install @urbica/react-map-gl
    
Published   Jul 19, 2022
Version   1.16.2
Author   Stepan Kuzmin
🌐
GitHub
github.com › urbica › react-map-gl
GitHub - urbica/react-map-gl: React Component Library for Mapbox GL JS · GitHub
import React, { useState } from 'react'; import MapGL from '@urbica/react-map-gl'; import 'mapbox-gl/dist/mapbox-gl.css'; const [viewport, setViewport] = useState({ latitude: 37.78, longitude: -122.41, zoom: 11 }); <MapGL style={{ width: '100%', height: '400px' }} mapStyle='mapbox://styles/mapbox/light-v9' accessToken={MAPBOX_ACCESS_TOKEN} latitude={viewport.latitude} longitude={viewport.longitude} zoom={viewport.zoom} onViewportChange={setViewport} />; Sources specify the geographic features to be rendered on the map.
Starred by 424 users
Forked by 49 users
Languages   JavaScript
Find elsewhere
🌐
React Map GL
visgl.github.io › adding custom data
Adding Custom Data | react-map-gl
By calling map.project() you can adjust the DOM or CSS properties so that the customly-drawn features are always aligned with the map. See a full example here. For more feature rich and performant data visualization overlay use cases, you may consider using other visualization libraries. react-map-gl ...
🌐
MapTiler
docs.maptiler.com › react › maplibre-gl-js › how-to-use-maplibre-gl-js
How to display MapLibre GL JS map using React JS | React | Maplibre gl js | MapTiler
Navigate to the newly created project folder my-react-map ... Inside the newly created project, you can run npm start to start your local environment. You will find your app running on address http://localhost:3000/. Now you should see the app in your browser. To install MapLibre GL library, navigate to your project folder and run the command: ... Navigate to the src folder and replace all the contents of the App.css ...
🌐
npm
npmjs.com › package › react-mapbox-gl
react-mapbox-gl - npm
November 26, 2020 - npm install react-mapbox-gl mapbox-gl --save · Example: Adding the css in your index.html: <html> <head> ... <link · href="https://api.mapbox.com/mapbox-gl-js/v1.10.1/mapbox-gl.css" rel="stylesheet" /> </head> </html> // ES6 · import ReactMapboxGl, { Layer, Feature } from 'react-mapbox-gl'; import 'mapbox-gl/dist/mapbox-gl.css'; // ES5 ·
      » npm install react-mapbox-gl
    
Published   Nov 26, 2020
Version   5.1.1
🌐
DEV Community
dev.to › sheenasany › how-to-use-mapbox-using-react-map-gl-v7-for-your-react-app-for-beginners-2o10
How to use Mapbox using React-Map-Gl V7 for your React App for beginners - DEV Community
November 1, 2022 - import Map, {Marker} from 'react-map-gl'; Also, you'll need to import css styling as well so we can have the ability to set height and width to our map or to add additional styling to your map if you want to get fancy.
🌐
GitHub
github.com › alex3165 › react-mapbox-gl
GitHub - alex3165/react-mapbox-gl: A React binding of mapbox-gl-js · GitHub
<html> <head> ... <link href="https://api.mapbox.com/mapbox-gl-js/v1.10.1/mapbox-gl.css" rel="stylesheet" /> </head> </html> // ES6 import ReactMapboxGl, { Layer, Feature } from 'react-mapbox-gl'; import 'mapbox-gl/dist/mapbox-gl.css'; // ES5 var ReactMapboxGl = require('react-mapbox-gl'); var Layer = ReactMapboxGl.Layer; var Feature = ReactMapboxGl.Feature; require('mapbox-gl/dist/mapbox-gl.css'); const Map = ReactMapboxGl({ accessToken: 'pk.eyJ1IjoiZmFicmljOCIsImEiOiJjaWc5aTV1ZzUwMDJwdzJrb2w0dXRmc2d0In0.p6GGlfyV-WksaDV_KdN27A' }); // in render() <Map style="mapbox://styles/mapbox/streets-v9" containerStyle={{ height: '100vh', width: '100vw' }} > <Layer type="symbol" id="marker" layout={{ 'icon-image': 'marker-15' }}> <Feature coordinates={[-0.481747846041145, 51.3233379650232]} /> </Layer> </Map>;
Starred by 2K users
Forked by 533 users
Languages   TypeScript 93.7% | CSS 3.1% | HTML 2.5%
🌐
LogRocket
blog.logrocket.com › home › using mapbox gl js with react
Using Mapbox GL JS with React - LogRocket Blog
June 4, 2024 - To be able to search for a user’s location, we will build on the capabilities of react-map-gl using a package called react-map-gl-geocoder, a React wrapper for the mapbox-gl-geocoder for use with react-map-gl. And, to add an overlay, we will be marking the area we have searched on our map. For greater readability, we will also be employing another visualization framework, deck-gl, also created by the Uber engineering team. We can install these two libraries with the command below: ... import "mapbox-gl/dist/mapbox-gl.css"; import "react-map-gl-geocoder/dist/mapbox-gl-geocoder.css"; import {
🌐
React Map GL
visgl.github.io › tips and tricks
Tips and Tricks | react-map-gl
const markers = useMemo(() => vehicles.map(vehicle => ( <Marker key={vehicle.id} longitude={vehicle.coordinates[0]} latitude={vehicle.coordinates[1]}> <svg> // vehicle icon </svg> </Marker>) ), [vehicles]); return ( <Map {...viewState} onMove={onMove} mapStyle="mapbox://styles/mapbox/streets-v9" > > {markers} </Map> ); } This prevents React from rerendering the markers unless they have changed. If your application can do without complicated DOM objects and CSS styling, consider switching to a symbol layer.
🌐
npm
npmjs.com › package › react-map-gl
react-map-gl - npm
3 weeks ago - React components for MapLibre GL JS and Mapbox GL JS. Latest version: 8.1.1, last published: 19 days ago. Start using react-map-gl in your project by running `npm i react-map-gl`. There are 482 other projects in the npm registry using react-map-gl.
      » npm install react-map-gl
    
Published   Apr 11, 2026
Version   8.1.1
🌐
DEV Community
dev.to › ivanbtrujillo › fit-viewport-to-markers-using-react-map-gl-3ig1
Fit viewport to markers using react-map-gl - DEV Community
December 20, 2020 - import React from "react"; import ReactMapGL, { Marker, NavigationControl } from "react-map-gl"; import "mapbox-gl/dist/mapbox-gl.css"; import "./map.css"; const MAP_STYLE = { width: "100%", height: "100%" }; const MAP_CONFIG = { maxZoom: 20, mapStyle: "mapbox://styles/mapbox/dark-v10", mapboxApiAccessToken: process.env.REACT_APP_MAPBOX_KEY }; export const Map: React.FC<unknown> = () => { const mapRef = React.useRef(); const mapContainerRef = React.useRef(null); const viewport = { width: 400, height: 400 }; return ( <div ref={mapContainerRef} className="map"> <ReactMapGL ref={mapRef} {...MAP_CONFIG} {...viewport}> <NavigationControl className="navigation-control" showCompass={false} /> </ReactMapGL> </div> ); };