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

2

6

I am adding Leaflet.markercluster plugin to my existing Leaflet map.

I am getting this error:

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

In relation to the line var locations = L.markerClusterGroup();.

I cannot find any information about what this error might mean.

I am linking to the Markercluster JS file, and after Leaflet. Not sure why else it would not be able to find a function.

Waldman answered 13/10, 2016 at 19:1 Comment(0)
P
12

That is the error you get when you use Leaflet version < 1 (e.g. 0.7.7) with Leaflet.markercluster version 1+ (e.g. 1.0.0)

Demo: https://jsfiddle.net/z6bc79dq/

As mentioned on the plugin home page:

Requires Leaflet 1.0.0

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

(Leaflet.markercluster version 0.5.0 is the latest compatible with Leaflet 0.7.x)

Pale answered 14/10, 2016 at 3:33 Comment(0)
T
1

I also got this error when I tried to add invalid layers (via the cluster group addLayers method) to a cluster group. (I was trying to add markers to a cluster group but the markers were not actually markers).

Hope this helps someone

Talia answered 27/1, 2019 at 4:16 Comment(2)
What's your solution of it? Also got this error is not an answer imho.Larcher
The supposed markers that I was adding to the cluster group were not actually marker instances but were something else. Check that the layers you are adding via addLayers are actually layersTalia

© 2022 - 2024 — McMap. All rights reserved.