I am using react project, so created create-react-app with tailwind Css by following this guide: https://tailwindcss.com/docs/guides/create-react-app, In my project I need to have Map so I can get the nearest location and so on. So followed this guidline: https://github.com/visgl/react-map-gl and also got the Access Token and Mapbox style from https://studio.mapbox.com/. I cannot figure out what is the reason that I cannot get Map to display on my webpage. Have googled and also have tried almost all the options mention in Stackoverflow but nothing seems to work for me. Some one suggested to add babel loader rules in craco.config.js file, but no luck with this either. Can anyone help me out with this. Will be much Appreciated!Thanks in Advance
My Map.js file:
import { useState } from "react";
import ReactMapGL, { Marker, Popup } from "react-map-gl";
//import getCenter from "geolib/es/getCenter";
// Adding Custom Environment Variables
function Map() {
const [viewport, setViewport] = useState({
width: "100",
height: "400",
latitude: 37.7577,
longitude: -122.4376,
zoom: 11,
});
return (
<div>
<h2 className="text-red-500">Map box map goes here....</h2>
<ReactMapGL
mapStyle="mapbox://styles/mapbox/ckszotu58a7dz17qh8ysv970j"
mapboxApiAccessToken={process.env.REACT_APP_MAPBOX_ACCESS_TOKEN}
{...viewport}
onViewportChange={(viewport) => setViewport(viewport)}
></ReactMapGL>
</div>
);
}
export default Map;
//======================================================
App.js file rendering it:
<main>
<section className="bg-gray-900 hidden xl:inline-flex xl:min-w-[300px]">
<Map />
</section>
</main>
// craco.config.js
module.exports = {
style: {
postcss: {
plugins: [require("tailwindcss"), require("autoprefixer")],
},
},
babel: {
loaderOptions: {
ignore: ["./node_modules/mapbox-gl/dist/mapbox-gl.js"],
},
},
};
// in package.json added the last two lines too
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all",
"not chrome < 51", // this
"not safari < 10" // and this
],