当使用react-leaflet-markercluster时出现错误“ TypeError:超级表达式必须为null或函数,而不是对象”

时间:2019-04-26 09:37:50

标签: reactjs leaflet react-leaflet

我想制作一组标记,但是在导入react-leaflet-markercluster后出现此错误msg TypeError: Super expression must either be null or a function, not object

我已经删除了我的node_modules文件夹并重新安装,然后对其进行了更新,但是仍然存在错误

import React from 'react';
import L from 'leaflet';
import { Map, TileLayer, Marker, Popup } from 'react-leaflet';
import MarkerClusterGroup from 'react-leaflet-markercluster';
import 'react-leaflet-markercluster/dist/styles.min.css';
import './style/dashboard.css';
import data from './../data/demo_data.json';

var myIcon = L.icon({
    iconUrl:'https://gkv.com/wp-content/uploads/leaflet-maps-marker-icons/map_marker-red.png',
    iconSize:[25, 41],
    iconAnchor:[12.5, 41],
    popupAnchor:[0, -41],
    shadowSize: [68, 95],
    shadowAnchor: [22, 94]
})
export default class Dashboard extends React.Component{
    state = {
        lat: 22,
        lng: 92,
        zoom: 7,
    }
    render() {
        const position = [this.state.lat, this.state.lng]
        return (
          <Map className="map" center={position} zoom={this.state.zoom}>
            <TileLayer
            attribution='&amp;copy <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
            url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
            />
            {data.map(item=>
                <Marker
                icon={myIcon} 
                position={[item.Latitude, item.Longitude]}
                >
                    <Popup>
                        'Hello'
                    </Popup>
                </Marker>
            )}
          </Map>
        )
    }
}```

0 个答案:

没有答案