Android Set массив состояний не работает.
React-native MapView componentWillMount состояние обновления устанавливает положение карты не работает. Помогите мне, пожалуйста.
Состояния:
constructor(props) {
super(props);
this.state = {
loading: '',
mapRegion: {
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
},
location: {
coords: {
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}
}
};
}
компонент будет монтироваться
async componentWillMount() {
this.setState({
mapRegion: {
latitude: responseJson.latitude,
longitude: responseJson.longitude,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
},
location: {
coords: {
latitude: responseJson.latitude,
longitude: responseJson.longitude,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}
},
});
}
Возвратный вид без изменения положения
<MapView style={{ width: '100%', height: '100%' }}
region={{
latitude: this.state.location.coords.latitude,
longitude: this.state.location.coords.longitude,
latitudeDelta: 3,
longitudeDelta: 3
}}
zoomEnabled = {true}>
<MapView.Marker coordinate={this.state.location.coords} title={strings('Location.Buradasiniz')} />
<MapView.Circle center={this.state.location.coords} radius={this.state.radius} strokeColor='red' fillColor="rgba(255, 0, 0, 0.20)"/></MapView>