I'm using react-native-maps
to render GOOGLE MAPS with loads of markers that I fetch from my co-worker's API. Bellow the map I have a FlatList
rendering data from every marker on the screen. The item in FlatList's renderItem
is a TouchableOpacity
. How can I focus on the marker callout when I press the corresponding button in the list?
ScreenShot:
code:
<Container>
<StatusBar
barStyle={theme.colors.statusDark}
backgroundColor={theme.colors.background1}
/>
<GoogleMaps>
{markers.map(marker => (
<MyMarker
key={marker.uid}
identifier={marker.uid}
markerLatitude={marker.position.lat}
markerLongitude={marker.position.lng}
title={marker.name}
address={marker.address}
cashback={marker.cashback}
/>
))}
</GoogleMaps>
<DivisorSimple />
<ListContainer>
{fetchIsLoading ? (
<ActivityIndicator size='large' />
) : (
<FlatList
data={markers}
renderItem={({ item }) => (
<ListMapItem
handleClick={() => {}
title={item.name}
address={item.address}
cashback={item.cashback}
handleGetRoute={() => handleGetRoute(item.position.lat, item.position.lng)}
/>
)}
keyExtractor={item => item.uid}
/>
)}
</ListContainer>
</Container>