Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 855
lycorine Avatar asked Oct 13 '16 19:10

lycorine


2 Answers

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)

like image 89
ghybs Avatar answered Oct 27 '22 09:10

ghybs


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

like image 41
Umair Ansari Avatar answered Oct 27 '22 08:10

Umair Ansari