reactjs - 如何修复“TypeError:leaflet__WEBPACK_IMPORTED_MODULE_7___default.a.markerClusterGroup 不是函数”
问题描述
我正在尝试在我的多个标记上实现标记集群,但我不断收到类型错误。
类型错误: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);
解决方案
推荐阅读
- ruby-on-rails - 登录 JWT 令牌在 localhost 上有效,但在 heroku 上无效——数据错误
- python - 如何使用 python 将 .odt 文件转换为 html
- java - 如果我以编程方式向其添加元素,则 ScrollView 不会滚动
- python - KFold with sklearn.model_selection shuffle 错误
- python - 如何提取像素的ARGB颜色
- arrays - 从以字母开头的列中提取值列表
- php - 标头位置后的PHP做某事
- django - AttributeError: 'NoneType' 对象在尝试使用 Q 过滤器获取最新记录时没有属性 'answer'
- r - 对于每一行,找到最接近指定值的列
- visual-studio - 如何在 Unity 项目中引用外部 DLL 而不将它们提交到存储库中?