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

onRegionChange and Region method both are not working together, only one is working.

Open Priti-dev opened this issue 3 years ago • 1 comments

As I have two options like

  1. by the search you can get the data of a particular location.
  2. 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:

  1. react-native: 0.65.1
  2. react-native-map-clustering: 3.4.2

As I am facing issues in both platforms IOS as well as Android.

Priti-dev avatar Nov 23 '21 11:11 Priti-dev

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>

Priti-dev avatar Nov 23 '21 13:11 Priti-dev