gpt4 book ai didi

javascript - react 中的 Mapbox(ReferenceError : L is not defined)

转载 作者:搜寻专家 更新时间:2023-10-31 23:24:09 24 4
gpt4 key购买 nike

我正在尝试让 React Mapbox 在一个小项目中工作。 https://www.npmjs.com/package/react-mapboxmap

import React from 'react';
import MapboxMap from 'react-mapbox';

class Operator extends React.Component {
render() {
return (
<div className='container'>
<MapboxMap
mapId="mapbox.comic"
zoomControl={false}
center={[59.907433, 30.299848]} zoom={17}
/>


</div>
);
}
}

export default Operator;

就像他们在 npm 包的描述页面上所说的那样。但是,我得到的只是这条错误消息:

ReferenceError: L is not defined

有什么想法吗?

最佳答案

尝试添加 <script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>

来自github page

Notice: this never was a full-feature library, merely a layer on top of Mapbox JS SDK. For a better, more full fledged solution, try react-leaflet (in conjunction with the Mapbox Maps API in our case).

关于javascript - react 中的 Mapbox(ReferenceError : L is not defined),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37332925/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com