Hello mitro’s
I am working on one of the web app there i want to show map on it. How can i show it on my site I have done some work by seeing docs but its not working in my project
MyCode:
import Map from ‘react-map-gl’;function Mapp() {return<MapinitialViewState={{longitude: -100,latitude: 40,zoom: 3.5}}style={{width: 600, height: 400}}mapStyle=’mapbox://styles/aryanpariyar/clbbzjybs000014muujyl5q6h’mapboxAccessToken={process.env.mapboxAccessToken}/>;}export default Mapp;

To implement Mapbox in a Next.js app using the latest version of react-map-gl, you will need to do the following:
npm install react-map-gl
oryarn add react-map-gl
to install the react-map-gl library in your Next.js app.head
element of your Next.js app’s_app.js
file to include the Mapbox CSS file:<link href='https://api.mapbox.com/mapbox-gl-js/v1.12.0/mapbox-gl.css' rel='stylesheet' />
Map
component. Pass your Mapbox access token as a prop to theMap
component, and set thestyle
prop to the style URL for the Mapbox style you want to use.For example:
import MapGL from 'react-map-gl';
const MyMap = () => {
return (
<MapGL
width={400}
height={400}
mapboxApiAccessToken={'YOUR_MAPBOX_ACCESS_TOKEN'}
style={"mapbox://styles/mapbox/streets-v11"}
/>
);
};
Map
component, such aslatitude
,longitude
, andzoom
to set the initial view of the map, oronViewportChange
to handle viewport changes. You can also add other Mapbox components, such asMarker
orPopup
, to add features to the map.For more information and examples, you can refer to the react-map-gl documentation.