-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Excluding some markers #2
Comments
Adding it doesn't make sense. If you don't want markers to be clustered then just keep them in two separate variables, one clustered, one not. Also, you should keep the marker for user location excluded anyways since it should be visually different from all other markers and you wouldn't want to recalculate and rerender all other markers every time user location changes. |
@JiriHoffmann Yes, but how am I supposed to exclude it, I only have one clustered map instance ? Of course, I want to exclude it and add a specific visual. Do you have a small example? I might be totally dumb but I don't get how Thanks :) |
No worries, I don't believe it is possible with the react-native-clustering library because it uses react-native-maps internally. The advantage of this library is that is not dependent on react-native-maps so you can organize your points however you want. Going off the example from the readme you could do something like this: import { useClusterer } from 'react-native-clusterer';
const MAP_DIMENSIONS = { width: MAP_WIDTH, height: MAP_HEIGHT }
//...
const [region, setRegion] = useState(initialRegion);
const
const [clusteredPoints, supercluster] = useClusterer(
markers,
MAP_DIMENSIONS,
regions
);
// ...
return (
<MapView
onRegionChangeComplete={setRegion}
// ... other props
>
{clusteredPoints.map((point) => (
<Marker
// ... marker props
>
{/*
// ... marker children - callout, custom marker, etc.
*/}
</Marker>
))}
{regularPoints.map((point) => (
<Marker
// ... marker props
>
{/*
// ... marker children - callout, custom marker, etc.
*/}
</Marker>
))}
{/* or even just a single marker with user location*/}
<Marker
// ... marker props
>
{/*
... marker children - callout, custom marker, etc.
*/}
</Marker>
/>
</MapView>
); |
Nice, thanks for this :-) |
I'm backporting the original issue because I think this repository might need it aswell.
tomekvenits/react-native-map-clustering#236
The text was updated successfully, but these errors were encountered: