react-native-cluster-map icon indicating copy to clipboard operation
react-native-cluster-map copied to clipboard

Doesn't load all locations in the map

Open raboija opened this issue 4 years ago • 3 comments

I swapped react native maps with this and it works well but it only show locations marked in my city not the rest of the map, but rendering with MapView of react native maps show all locations. Is there something that's causing this and I can change it?

raboija avatar Oct 23 '20 12:10 raboija

code?

stothet avatar Mar 01 '21 12:03 stothet

Same thing happening here, I'm using a custom component from ClusterMap and it just renders markers near me, here a example code: https://gist.github.com/devmeireles/63e7e1b4023c9c29c7d25b8582372ec1

devmeireles avatar Mar 02 '22 13:03 devmeireles

Hi, I'm facing the same issue. Only the markers present in the original "region" props are shown on the map. Markers that are not in the rectangle obtained with {latitude, longitude, latitudeDelta, longitudeDelta} seems to be created and loaded, but we can't see them on the map.

To reproduce the issue, you only have to set a small latitudeDelta & longitudeDelta, and then zoom out. You should not be able to see markers outside the rectangle corresponding to your original "region" props.

I didn't find any fix for this issue, but a small workaround. I took a very big latitudeDelta & longitudeDelta for the original 'region" props (something like 20 so i can see the whole country i'm working on in the first render of the map). The whole country being in the rectangle corresponding to my original "region" props, all markers in the country can be seen. Then, passing a ref to ClusterMap, I used the method animateToRegion in a useEffect to initialize the first zoomed region I want to see.

const ref = useRef(null)

React.useEffect( () => {
    if (ref.current) {
        ref.current.mapRef.animateToRegion({
            latitude: LATITUDE, 
            longitude: LONGITUDE,
            latitudeDelta: 0.03,
            longitudeDelta: 0.03,
        }, 2000)
    }
}, [ref.current])

return (
    <ClusterMap 
        ref={ref}
        region={{
            latitude: LATITUDE,
            longitude: LONGITUDE,
            latitudeDelta: 20,
            longitudeDelta: 20,
        }} 
    >
        {YOUR_MARKERS}
    </ClusterMap>
)

Naowak avatar Mar 08 '22 10:03 Naowak