Leaflet 将传单与传单一起使用时,缺少_icon选项和_icon.classList

Leaflet 将传单与传单一起使用时,缺少_icon选项和_icon.classList,leaflet,leaflet.markercluster,Leaflet,Leaflet.markercluster,有人能解释一下为什么我这样做,将点从一层移动到另一层: var previousLayer = activeItem.getLayers()[0]; activeItem.removeLayer(previousLayer); // activeItem is FeatureGroup mapItems.addLayer(previousLayer); // mapItems is MarkerClusterGroup 然后尝试使用以下命令更改标记类: previousLayer._icon

有人能解释一下为什么我这样做,将点从一层移动到另一层:

var previousLayer = activeItem.getLayers()[0];

activeItem.removeLayer(previousLayer); // activeItem is FeatureGroup
mapItems.addLayer(previousLayer); // mapItems is MarkerClusterGroup
然后尝试使用以下命令更改标记类:

previousLayer._icon.classList.remove('marker-active');
previousLayer._icon.classList.add('marker-shown');
当标记进入地图上可见的簇内时,我得到并错误地认为_图标为空

是某种MarkerCluster bug还是我遗漏了什么

顺便说一句,我试图找到父簇,循环遍历其中的所有标记,所有这些标记都没有_图标选项

angular.forEach(mapItems.getVisibleParent(previousLayer)._markers, function (marker) {
     console.log(marker._icon); // error every time
});
是某种MarkerCluster bug还是我遗漏了什么

不。如果您以前没有注意到,任何前面带有uu的内容在传单术语中都是私有变量。这意味着,如果你依赖任何前面有一个uu的东西,当你需要它时,它会很容易被打破

  • 更新单张
  • 使用插件
  • 使用不同的浏览器
这种破损不是传单的错,而是你自己的错

回答:不要使用
\u图标
,在这种情况下,请使用
console.log
查看标记的类型