响应中的Mapbox (ReferenceError: L未定义)

时间:2021-03-07 20:26:11

I'm trying to get react mapbox to work in a small project. https://www.npmjs.com/package/react-mapboxmap

我正在尝试用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;

Just like they say on the description page for the npm package. However, all I get is this error message:

就像他们在npm包的描述页面上说的那样。然而,我得到的只是这个错误信息:

ReferenceError: L is not defined

Any ideas?

什么好主意吗?

2 个解决方案

#1


1  

Try adding <script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>

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

From the github page

从github页面

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).

注意:这不是一个完整的功能库,仅仅是Mapbox JS SDK的一层。对于一个更好的、更成熟的解决方案,可以尝试使用反应传单(在我们的例子中与Mapbox地图API一起使用)。

#2


0  

This is what you wanted to do ->

这就是你想做的->。

import L from 'leaflet';

从“传单”进口L;

#1


1  

Try adding <script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>

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

From the github page

从github页面

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).

注意:这不是一个完整的功能库,仅仅是Mapbox JS SDK的一层。对于一个更好的、更成熟的解决方案,可以尝试使用反应传单(在我们的例子中与Mapbox地图API一起使用)。

#2


0  

This is what you wanted to do ->

这就是你想做的->。

import L from 'leaflet';

从“传单”进口L;