Wrap maplibre-gl in the official react-map-gl adapter for declarative React components. Drop in <Map> + <Source> + <Layer> and stay purely React, with no imperative DOM ref handling.
pnpm add maplibre-gl react-map-glimport 'maplibre-gl/dist/maplibre-gl.css';
import Map, { Source, Layer, NavigationControl } from 'react-map-gl/maplibre';
const MAP_STYLE = 'https://maps.guru/api/v1/styles/standard/light/style.json?key=YOUR_API_KEY';
export function CityMap() {
return (
<Map
initialViewState={{ longitude: 77.209, latitude: 28.6139, zoom: 11 }}
mapStyle={MAP_STYLE}
style={{ width: '100%', height: 480 }}
>
<NavigationControl position="top-right" />
<Source
id="places"
type="geojson"
data="https://maps.guru/api/v1/datasets/your-dataset/geojson?key=YOUR_API_KEY"
>
<Layer
id="places-fill"
type="circle"
paint={{
'circle-radius': 6,
'circle-color': '#ff6b00',
'circle-stroke-width': 2,
'circle-stroke-color': '#ffffff',
}}
/>
</Source>
</Map>
);
}
Free-tier generous enough for real production traffic. 50,000 tile requests/month , no credit card.
Join developers worldwide who trust maps.guru for their mapping needs. Start free, no credit card required.