Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

**React Native Maps** - How do I zoom on Marker pressed?

$
0
0

For my internship, I have to create an app with a Maps view and markers called from an API (the standard GraphQL API). But I have to make the map Zoom on the marker when I click on it, and I don't understand how I can do that.
I looked for the documentation and I didn't understand it :animateCamera(camera: Camera, {duration: number})But what is a camera object ? I don't have one. And how can I call animateCamera ? With a ref (_mapRef.current.animateCamera) ?

Here is my code :

<MapView  style={styles.map}  mapType={viewType}  provider='google'  ref={_map}>  {users !== undefined && users.map((item, index) => (<Marker      key={'user_'+ index}      title={item.username}      description={item.posts.data.length +' posts'}      coordinate={{        latitude: item.address.geo.lat,        longitude: item.address.geo.lng      }}      onCalloutPress={() => {        navigation.navigate('SingleUser', {user: item})      }}    />  ))}</MapView>

Thanks for the help

PS: This is my first question on Stack, please don't be rude and do not hesitate to tell me if I missed a rule ! :)

PPS: Why does Stack delete my 'Hello' I put at the beginning everytime I edit this post ?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>