我添加了mapplibregl在我的react js项目,但https://api.maptiler.com/tiles/v3/2/0/2.pbf?key=my-key不加载
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}
});
我找到了答案:您应该将版本更改为
"maplibre-gl": "^1.15.2",
package.json中的。然后别忘了npm i。