我通过 axios 和 setState 将地理编码位置获取到 latt,lngg 变量中,我想在 google-map-react 包中心使用这个变量我如何将这些状态值传递给 props 。
休息 API
then(res => {
console.log(res.data.results[0].geometry.location.lat);
console.log(res.data.results[0].geometry.location.lng);
// console.log(res.data[0]);
this.setState({latt:res.data.results[0].geometry.location.lat})
this.setState({lngg:res.data.results[0].geometry.location.lng})
})
static defaultProps = {
center: {
lat: 32,
lng: 56
},
zoom: 5.7
};
<GoogleMapReact bootstrapURLKeys={{ key:API-KEY}} defaultCenter={this.props.center} defaultZoom={this.props.zoom}>