javascriptreactjsmaplibre-gl

maplibregl doesn't show in production


I add maplibregl in my react js project but https://api.maptiler.com/tiles/v3/2/0/2.pbf?key=my-key does not load.

map = new maplibregl.Map({
            container: 'map',
            style: 'https://api.maptiler.com/maps/basic/style.json?key=my-key', // stylesheet location
            
            center: [-122.4849334359169, 37.829298101706186], // starting position [lng, lat]
            zoom: 13, // starting zoom
            renderWorldCopies: true,
            bounds:[listShips[0].geometry.coordinates,listShips[1].geometry.coordinates],
            fitBoundsOptions: {padding: 300}
        });

Solution

  • I have found the answer: you should change the version to

       "maplibre-gl": "^1.15.2",
    

    on your package.json. Then don't forget to npm i .