-
Notifications
You must be signed in to change notification settings - Fork 299
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
Duplicate coordinates throwing No cluster with the specified ID
#103
Comments
@ollieh-m thanks for the report! In theory, duplicate points shouldn't be a problem for the library. Would it be possible to set up a minimal reproducible test case so that I could investigate what's going on under the hood? |
Closing because of not being able to reproduce this. Will reopen if there's a minimal reproducible use case. |
I’m having the same problem and is clearly because of points with exactly the same coordinates inside the cluster. Initially I set the Playing with For the record, but it would be good to fix the (By the way, amazed that nobody else complained in more than two years!) |
@djibarian thanks for bringing this up! Would you be able to set up a minimal test case for this so that I could promptly provide a fix? |
We had the same problem (with a lot of duplicate coordinate), we set the cluster maxZoom to 30 and everything works. |
@mourner How do I do that? Do you have a sandbox or playground I can set up? |
@djibarian you could just use https://jsfiddle.net/ or https://jsbin.com/ |
To reproduce the error :
To fix it adjust the maxZoom to a value under 31 The code I used
|
@ozaik would you mind turning this into a minimal (purely Supercluster without other libraries), live (a link to JSFiddle/JSBin) test case? |
Hello! I copied the example made by @ozaik into a codesandbox and adapted it so we can see the issue without any external library. Only supercluster here. Here's the link to the codesandbox: https://codesandbox.io/s/supercluster-no-cluster-with-the-specified-id-rtiqk?file=/src/index.js - I know it's not JSFiddle/JSbin, but I hope it's sufficient as a test case (as you don't need an account to mess with it either) By the way. I'm having the same issue while using supercluster with the ol-supercluster: I get an apparently valid cluster_id (9) by scanning the output of |
release 7.1.4 fixed it for me |
Fantastic! So this might have been the same issue as #189. 🎉 Let's close this one for now then, unless anyone is still experiencing problems on the latest version. |
@mourner Before closing the issue, could you please have checked the example I posted in the comment above? For some weird scenarios, this issue still happens, even on version 7.1.4. Here's the updated codesandbox with the code still failing on 7.1.4: https://codesandbox.io/s/supercluster-no-cluster-with-the-specified-id-forked-r8jc6?file=/src/index.js Thanks. |
(My issue wasn't related to zoom level, but it did fix the exception thrown when iterating over clusters and trying to use getLeaves on a cluster) |
Also having this issue with |
On my case, if this helps someone was: const [points, supercluster] = useClusterer(
debouncedDataToBeMerged ? debouncedDataToBeMerged : [],
SCREEN,
mapCoordsDebounced,
SUPERCLUSTER_OPTS
); I have this hook that creates a supercluster instance, but forgot to add the dep into onClusterPress: const onClusterPress = useCallback(
async (clusterId: number) => {
{
const regionToAnimate = supercluster.expandCluster(clusterId);
const zoom = supercluster.getClusterExpansionZoom(clusterId);
mapRef.current?.animateCamera({
center: {
...regionToAnimate,
},
zoom: zoom + 2,
});
}
},
- [],
+ [supercluster]
); |
Issue still happening on version |
I'm also facing the same issue using the you can reproduce it using the code below: import React from "react";
import MapView from "react-native-map-clustering";
import { Marker } from "react-native-maps";
const INITIAL_REGION = {
latitude: 52.5,
longitude: 19.2,
latitudeDelta: 8.5,
longitudeDelta: 8.5,
};
const App = () => (
<MapView initialRegion={INITIAL_REGION} style={{ flex: 1 }}>
<Marker coordinate={{ latitude: 52.4, longitude: 18.7 }} />
<Marker coordinate={{ latitude: 52.4, longitude: 18.7 }} />
<Marker coordinate={{ latitude: 52.4, longitude: 18.7 }} />
</MapView>
);
export default App; my solution (tricky one) was to add some small noise to the markers by doing something like let markers = listItems.map((item, index) => {
const randomNoiseLat = Math.random() * 0.0001
return <Marker
key={`marker-id-${index}`}
coordinate={{
latitude: parseFloat(`${item.lat}`) + randomNoiseLat,
longitude: parseFloat(`${item.lng}`)
}} />
} but still it's not a real fix, just bypassing the issue |
We are using Supercluster wrapped in https://github.com/novalabio/react-native-maps-super-cluster
On loading our map, we've experienced the
No cluster with the specified ID
error when clicking on a cluster. This was happening within the following call togetLeaves()
, whereclusteringEngine
is Supercluster.It turns out the error happened when a cluster had two points that shared exactly the same coordinates, leading to the below stack trace, where I log out from the
getChildren()
function. As you can see, it thinks the child of the cluster is also a cluster at the same coordinates, and the child of that cluster is also apparently a cluster at the same coordinates, but that 'cluster' doesn't have any children IDs so the error is thrown.I'm wondering:
getChildren
cannot find the children for a cluster, an empty array should be returned rather than an error thrown. Or perhaps_appendLeaves
should setchildren
to an empty array if the error gets thrown, like this:Stack trace:
The text was updated successfully, but these errors were encountered: