Marek Pruszkowski
Marek Pruszkowski

Reputation: 1

React native maps clusterer problem with disappearing clusters

Markers keep disappearing while zooming in or moving on the map despite console log saying they are being rendered. I've tried rendering the bounding box of the region and it seems to be ok. Markers are just

Here is a part of my code:


const MapComponent = () => {
    const [markers, setMarkers] = useState<any[]>([]);
    const [region, setRegion] = useState<Region>(initialRegion);
    const mapRef = useRef<MapView>(null);

    const _handlePointPress = (point: IFeature) => {
        if (isPointCluster(point)) {
            const toRegion = point.properties.getExpansionRegion();
            mapRef.current?.animateToRegion(toRegion, 500);
        }
    };

    return (
        <View style={styles.container}>
            <MapView
                ref={mapRef}
                initialRegion={initialRegion}
                onRegionChangeComplete={setRegion}
                style={MAP_DIMENSIONS}
            >
                <Clusterer
                    data={markers}
                    region={region}
                    options={{ radius: 18 }}
                    mapDimensions={MAP_DIMENSIONS}
                    renderItem={(item) => {
                        console.log;
                        return (
                            console.log("rendering item", item),
                            (
                                <Point
                                    key={
                                        isPointCluster(item)
                                            ? `cluster-${item.properties.cluster_id}`
                                            : `point-${item.properties.id}`
                                    }
                                    item={item}
                                    onPress={_handlePointPress}
                                />
                            )
                        );
                    }}
                />
            </MapView>
        </View>
    );
};


Upvotes: 0

Views: 33

Answers (0)

Related Questions