Open JLeggatt opened 7 years ago
cf @Wykks
Did you find any solution?
My code worked ok, however I get same issue when I upgrade to latest version of mapbox-gl, react-mapbox-gl and @mapbox/mapbox-gl-draw
New versions,
"mapbox-gl": "^0.41.0",
"react-mapbox-gl": "3.1.0",
"@mapbox/mapbox-gl-draw": "^1.0.4",
"@mapbox/mapbox-gl-draw-static-mode": "^1.0.1",
Previous version worked OK with following versions
"@mapbox/mapbox-gl-draw": "^0.18.1",
"mapbox-gl": "^0.37.0",
"react-mapbox-gl": "^1.11.0",
Error,
index.js:82 Uncaught TypeError: Cannot read property 'points' of undefined
at SuperCluster.getChildren (index.js:82)
at SuperCluster._appendLeaves (index.js:147)
at SuperCluster.getLeaves (index.js:100)
at FloorMap.selectCluster (floor-map.js:853)
at e.<anonymous> (floor-map.js:923)
at e.s (mapbox-gl.js:456)
at e.Evented.fire (mapbox-gl.js:482)
at h (mapbox-gl.js:422)
at HTMLDivElement.s (mapbox-gl.js:422)
File: webpack:///./node_modules/supercluster/index.js Module:
var kdbush = require('kdbush');
module.exports = supercluster;
i had the same problem (Cannot read property 'points' of undefined) , it was fixed by adding a second argument getChildren(feature.properties.cluster_id,0)
getChildren: function(t, n) { for (var o = this.trees[n + 1].points[t], e = this.options.radius / (this.options.extent * Math.pow(2, n)), i = this.trees[n + 1].within(o.x, o.y, e), r = [], u = 0; u < i.length; u++) { var a = this.trees[n + 1].points[i[u]]; a.parentId === t && r.push(a.numPoints ? s(a) : this.points[a.id]) } return r }
when n is undefined => this.trees[n + 1] = undefined i think the second argument must be the zoom
-- i also got another problem (Cannot read property 'points' of undefined) because i tried to getChilden of a signle marker, so i had to check that i am working with a cluster before using getChildren
When passing
true
to the zoomOnClick prop to a cluster, it throws an errorthis is due to the
clusterZoom
property ofgetChildren
method being set toInfinity
, therefore it can never access the array.Using the cluster, almost exactly like the example.
Any thoughts?