hey i am trying to add overlay marker which stays in center of the screen like this even if we scroll or zoom the screen
i tried moving marker from its initial position but it lags behind when we move screen fast. so i want to set marker image in the center of the screen
here is the code what i have done to move marker:
componentDidMount: function() {
this.fetchData();
navigator.geolocation.getCurrentPosition(
(position) => {
this.setState({
region: {
latitude: position.coords.latitude,
longitude: position.coords.longitude,
latitudeDelta: LATITUDE_DELTA,
longitudeDelta: LONGITUDE_DELTA
}
});
},
);
this.watchID = navigator.geolocation.watchPosition((position) => {
const newRegion = {
latitude: position.coords.latitude,
longitude: position.coords.longitude,
latitudeDelta: LATITUDE_DELTA,
longitudeDelta: LONGITUDE_DELTA
}
this.onRegionChange(newRegion);
});
},
componentWillUnmount: function() {
navigator.geolocation.clearWatch(this.watchID);
},
onRegionChange(region) {
this.setState({ region });
},
so how can i overlay a marker image?
justifyContent: "center", alignItems: "center"
to theView
that wraps theIcon
and theMapView
, So you don't have to give those four lines of style to yourIcon
(I mean the last 4 lines of theIcon
style,marginTop
,marginLeft
,left
andtop
. It also doesn't get messed on different devices. – Homburg