Roozbeh Mohammadzadeh
Roozbeh Mohammadzadeh

Reputation: 689

how to get the location which we are viewing by react native map box?

i want to get the lat and lang of location while moving map

i mean console.log(regain) or something like this

i try onRegionDidChange but i could not find a way out

           <Mapbox.MapView
        styleURL={Mapbox.StyleURL.Street}
        zoomLevel={15}
        onRegionDidChange={this.onRegionDidChange}
        logoEnabled={false}
        showUserLocation={true}
        centerCoordinate



{[parseFloat(this.state.longitude),parseFloat(this.state.latitude)]}
        style={styles.container}>

    </Mapbox.MapView>

Upvotes: 2

Views: 612

Answers (1)

Amal p
Amal p

Reputation: 3052

You will get values from callback in every methods like onRegionDidChange and onRegionIsChanging etc.

Log the value from callback and maybe you will need to stringify it.

  onRegionDidChange={(values)=>{console.log(values)}}

   or

  onRegionIsChanging={(values)=>{console.log(JSON.stringify(values))}}

Inside the values there maybe values other than co-ordinates

Take only what you need like for if there is a value lat(latitude). Get the value as

values.lat

Upvotes: 4

Related Questions