react-native-map-clustering
react-native-map-clustering copied to clipboard
onRegionChange and Region method both are not working together, only one is working.
As I have two options like
- by the search you can get the data of a particular location.
- from the tap or click on a marker you will get the data.
In the first case, it's working but, the 2nd one will work if the region is not defined,
version details:
- react-native: 0.65.1
- react-native-map-clustering: 3.4.2
As I am facing issues in both platforms IOS as well as Android.
Please check my code.
<MapView
ref={mapRef}
provider={PROVIDER_GOOGLE}
initialRegion={INITIAL_REGION}
followsUserLocation={true}
showsMyLocationButton={true}
showsUserLocation={true}
onRegionChange={() => props.setSearch()}
region={props?.initialRegion.latitude !== '' ? regionVal : INITIAL_REGION}
onRegionChangeComplete={(region) => setRegion(region)}
draggable={true}
region={props?.initialRegion.latitude !== '' ? regionVal : INITIAL_REGION}
clusterColor={colors.CLR_PRIMARY} spiderLineColor={'yellow'}
style={{ flex: 1, }}
>
{props.data?.map((item, index) => {
return (
<Marker draggable coordinate={{ latitude: parseFloat(item.latitude), longitude: parseFloat(item.longitude) }} onPress={e => props.onPress(e.nativeEvent, index)} onDragEnd={(e) => setRegion({ ...e.nativeEvent.coordinate })} key={index}>
<Image
source={IMAGES.marker_icon}
style={{ height: 35, width: 35, resizeMode: 'cover' }} />
</Marker>
)
})}
</MapView>