Coder Social home page Coder Social logo

Can't access cluster leaves about supercluster HOT 2 CLOSED

mapbox avatar mapbox commented on May 17, 2024 8
Can't access cluster leaves

from supercluster.

Comments (2)

jameslin123 avatar jameslin123 commented on May 17, 2024 1

Looking into the 'getLeaves' method, it expects a 'properties' field for every child:

var props = children[i].properties;
 if (props.cluster) { ...

But a leaf child doesn't get initialized with the "properties" field, so props.cluster would error out.

Perhaps the proper fix is to create such a field for the 'points' inside the index loader.

As a workaround, we can mock that field in the "points" array which we feed to index.load():

const points = items.map(
            (item) => {
                return {
                    geometry: item.geometry,
                    item: item,

                    // Workaround: getLeaves expects this field for a leaf node.
                    properties: {
                        cluster: false
                    }
                };
            });

 index.load(points);

The getLeaves method returns leaf nodes with this workaround.

from supercluster.

jzzfs avatar jzzfs commented on May 17, 2024

@jameslin123 thank you! This solved my problem.

from supercluster.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.