Leaflet Markercluster - “this._featureGroup.addEventParent is not a function”

旧时模样 提交于 2019-12-07 10:12:59

问题


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.


回答1:


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)




回答2:


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



来源:https://stackoverflow.com/questions/40028929/leaflet-markercluster-this-featuregroup-addeventparent-is-not-a-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!