Estou tentando colocar um ícone de localização no mapa, às vezes, após uma recarga, o ícone sai do contêiner em que deveria estar embrulhado. Abaixo estão as imagens do que estou me referindo, alguém pode ajudar com isso.
outras vezes, ele se alinha corretamente
abaixo está o meu código
<MapView
style={map}
region={region}
showsUserLocation
loadingEnabled
showsCompass
showsTraffic
onRegionChangeComplete={this.onRegionChangeComplete}
onRegionChange={this.onRegionChange}
ref={el => (this.mapView = el)}
>
<Fragment>
<LocationButton
onPress={this.refocus}
style={locationFocus}
/>
</Fragment>
</MapView>
)}
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
map: {
position: 'absolute',
flex: 1,
width: '100%',
height: '100%',
},
locationFocus: {
position: 'absolute',
bottom: 200,
right: 20,
}
});
Remova "LocationButton" do contêiner MapView e adicione no contêiner principal
<View style={{flex:1}}>
<MapView
style={map}
region={region}
showsUserLocation
loadingEnabled
showsCompass
showsTraffic
onRegionChangeComplete={this.onRegionChangeComplete}
onRegionChange={this.onRegionChange}
ref={el => (this.mapView = el)}
>
</MapView>
<Fragment>
<LocationButton
onPress={this.refocus}
style={locationFocus}
/>
</Fragment>
</View>
Este artigo é coletado da Internet.
Se houver alguma infração, entre em [email protected] Delete.
deixe-me dizer algumas palavras