I was looking at this example because I wanted to show the current location on the map, just struggling to write the example in my own code
https://github.com/react-native-community/react-native-maps this is exsample
getInitialState() {
return {
region: {
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
},
};
}
onRegionChange(region) {
this.setState({ region });
}
render() {
return (
<MapView
region={this.state.region}
onRegionChange={this.onRegionChange}
/>
);
}
my code is not funcition.
const Map = () => {
render(){
const getInitialState =() => {
return {
region: {
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
},
}
};
const onRegionChange = (region) => {
this.setState({ region });
}
return (
<MapView
style={styles.map}
region={this.state.region}
onRegionChange={this.state.onRegionChange}
/>
)
}
}
export default Map;
I'm having trouble writing the example code myself. How to make funciton work well