-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainScreen.js
61 lines (46 loc) · 1.61 KB
/
MainScreen.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import React from 'react';
import {Text, View} from 'react-native';
import MapView from 'react-native-maps';
import styles from './style.js'
export default class MainScreen extends React.Component {
constructor(props){
super(props);
this.state = {weatherApiParam: 'init',
marker:{
coordinates: {
latitude: 3.148561,
longitude: 101.652778
},
}
};
}
static navigationOptions = ({ navigation }) => ({
title: ` ${navigation.state.params.city}`,
});
// componentDidMount(){
// fetch(`http://api.apixu.com/v1/current.json?key=0c82c413a5ca4c80a7f123530171010&q=${this.props.navigation.state.params.city}`)
// .then((response) => response.json())
// .then((responseJson) => {this.setState({weatherApiParam: responseJson.current.temp_c});})
// .catch((error) => {
// console.error(error);
// })
//
// }
render() {
var MapView = require('react-native-maps');
const { params } = this.props.navigation.state;
return (
<View style={styles.container}>
<MapView style={styles.map}
initialRegion={{
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
/>
{/*<Text>Current temperature in {params.city}: {this.state.weatherApiParam} C</Text>*/}
</View>
);
}
}