如何通过反应本机地图框获取我们正在查看的位置?
how to get the location which we are viewing by react native map box?
我想在移动地图时获取位置的经纬度
我的意思是console.log(重新获得)或类似的东西
我尝试 onRegionDidChange 但我找不到出路
<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>
您将在 onRegionDidChange 和 onRegionIsChanging 等每个方法中从回调中获取值
从回调中记录值,也许您需要将其字符串化。
onRegionDidChange={(values)=>{console.log(values)}}
or
onRegionIsChanging={(values)=>{console.log(JSON.stringify(values))}}
在 values
中可能有 co-ordinates
以外的值
只取你需要的 就像有一个值lat
(纬度)一样。获取值为
values.lat
我想在移动地图时获取位置的经纬度
我的意思是console.log(重新获得)或类似的东西
我尝试 onRegionDidChange 但我找不到出路
<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>
您将在 onRegionDidChange 和 onRegionIsChanging 等每个方法中从回调中获取值
从回调中记录值,也许您需要将其字符串化。
onRegionDidChange={(values)=>{console.log(values)}}
or
onRegionIsChanging={(values)=>{console.log(JSON.stringify(values))}}
在 values
中可能有 co-ordinates
只取你需要的 就像有一个值lat
(纬度)一样。获取值为
values.lat