Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing one point does not return any values #146

Open
tbaustin opened this issue Dec 18, 2019 · 1 comment
Open

Passing one point does not return any values #146

tbaustin opened this issue Dec 18, 2019 · 1 comment
Labels

Comments

@tbaustin
Copy link

I assume since one point cannot be a cluster it just doesn't return it, but this breaks code for me. Could we return the point without a cluster_id or something?

Here is the example and code:

Test Code

POINTS:  [
  {
    "id": "marker-7659",
    "lat": "33.65",
    "lng": "-86.68",
    "address": {
      "address": "PO Box 94520",
      "city": "Birmingham",
      "state": "AL",
      "zip": "35220",
      "country": "US"
    },
    "geometry": {
      "coordinates": [
        "-86.68",
        "33.65"
      ]
    }
  }
]
BOUNDS:  {
  "ne": {
    "lat": 33.65,
    "lng": -86.68
  },
  "nw": {
    "lat": 33.65,
    "lng": -86.68
  },
  "se": {
    "lat": 33.65,
    "lng": -86.68
  },
  "sw": {
    "lat": 33.65,
    "lng": -86.68
  }
}
ZOOM:  8

Supercluster code

const clusters = index
		.load(points)
		.getClusters(
			[bounds.sw.lng, bounds.sw.lat, bounds.ne.lng, bounds.ne.lat],
			zoom
		)
		.map(cluster =>
			cluster.type === 'Feature'
				? {
						id: cluster.id,
						lat: cluster.geometry.coordinates[1],
						lng: cluster.geometry.coordinates[0],
						point_count: cluster.properties.point_count,
						cluster_id: cluster.properties.cluster_id,
						// onclick to get correct zoom
						getZoom: () =>
							index.getClusterExpansionZoom(cluster.properties.cluster_id)
				  }
				: cluster
		)

This just returns and empty array

@mourner mourner added the bug label Jan 17, 2020
@AsnelChristian
Copy link

I have the same issue. getCluster seems to be buggy for fewer points

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants