传单标记集群 - "this._featureGroup.addEventParent is not a function"

Leaflet Markercluster - "this._featureGroup.addEventParent is not a function"

我正在添加 Leaflet.markercluster plugin to my existing Leaflet 地图。

我收到此错误:

Uncaught TypeError: this._featureGroup.addEventParent is not a function

相对于行 var locations = L.markerClusterGroup();

我找不到关于此错误可能意味着什么的任何信息。

我正在链接到 Markercluster JS 文件,在 Leaflet 之后。不知道为什么它找不到函数。

这是当您将 Leaflet 版本 < 1(例如 0.7.7)与 Leaflet.markercluster 版本 1+(例如 1.0.0

一起使用时出现的错误

演示:https://jsfiddle.net/z6bc79dq/

如插件中所述home page

Requires Leaflet 1.0.0

For a Leaflet 0.7 compatible version, use the leaflet-0.7 branch

(Leaflet.markercluster 版本 0.5.0 是最新兼容 Leaflet 0.7.x)

当我尝试将无效图层(通过群集组 addLayers 方法)添加到群集组时,我也遇到了这个错误。 (我试图将标记添加到集群组,但这些标记实际上并不是标记)。

希望这对某人有所帮助