Reputation: 538
I am trying to place a location icon on the map, sometimes after a reload, the icon leaves the container it is supposed to be wrapped in. below are images of what I am referring to, can anyone help with this.
other times it aligns properly
below is my code
<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,
}
});
Upvotes: 0
Views: 1027
Reputation: 3636
Remove "LocationButton" from MapView Container and add in main container
<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>
Upvotes: 1