具有标记簇的聚类折线

问题描述

我尝试使用Ghybs solution for adding polygon进行聚类,但是另外还用于折线。

    L.polyline.addInitHook(function () {
    // @ts-ignore
    this._latlng = this._bounds.getCenter();
});

L.polyline.include({
    getLatLng: function () {
        return this._bounds.getCenter();
    },setLatLng: function () {} // Dummy method.
});



L.polygon.addInitHook(function () {
    // @ts-ignore
    this._latlng = this._bounds.getCenter();
});

// Provide getLatLng and setLatLng methods for Leaflet.markercluster to be able to cluster polygons.
L.polygon.include({
    getLatLng: function () {
        return this._latlng;
    },setLatLng: function () {} // Dummy method.
});

我遇到的问题是,我正在使用传单-geoman编辑(本质上是更新位置)对象。这将导致折线在更改时不存在纬度。 出现此错误Uncaught TypeError: Cannot read property 'lat' of undefined

enter image description here

添加折线代码后,多边形也会发生这种情况。删除折线代码后,多边形可以正常工作。

总结:我需要对多边形和折线进行聚类,导致折线引起问题,我不明白为什么。

此外,折线实际上会在初始地图加载时聚类。仅在对折线执行更改时才会发生此问题。 (但是如果删除折线代码,则多边形不会发生这种情况)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...