如何修复“ TypeError:leaflet__WEBPACK_IMPORTED_MODULE_7 ___ default.a.markerClusterGroup不是函数”

时间:2019-04-02 05:55:58

标签: reactjs leaflet leaflet.markercluster

我正在尝试在多个标记上实现标记集群,但是我一直遇到类型错误。

  

TypeError:leaflet__WEBPACK_IMPORTED_MODULE_7 ___ default.a.markerClusterGroup不是函数

this.map = L.map('map',{
            center:[28,84],
            zoom:7,
        });

        let locations = [
            ["LOCATION_1",28, 84],
            ["LOCATION_2",28.2, 85],
            ["LOCATION_3",28.1, 84],
            ["LOCATION_4",28.1, 84],
            ["LOCATION_5",28.01, 84]
        ];

        let greenIcon = L.icon({
            iconUrl: 'someUrl',        
            iconSize:[30, 30], // size of the icon
         });

         let markers = L.markerClusterGroup();

         for (let i = 0; i < locations.length; i++) {
            let marker = new L.marker([locations[i][1],locations[i][2]], {icon: greenIcon})
                .bindPopup(locations[i][0])
                .addTo(this.map);
            markers.addLayer(marker);
        }

        this.map.addLayer(markers);

0 个答案:

没有答案