-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathApp.js
More file actions
39 lines (33 loc) · 954 Bytes
/
App.js
File metadata and controls
39 lines (33 loc) · 954 Bytes
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
import React, {Component} from 'react';
import {DeviceEventEmitter, StyleSheet, requireNativeComponent, UIManager, findNodeHandle} from 'react-native';
import cities from './us_cities.json'
const mapRef = React.createRef()
const GMap = requireNativeComponent('GMap')
export default class App extends Component {
constructor(props){
super(props)
this.state = {}
this.onMapReady = this.onMapReady.bind(this)
}
onMapReady(){
cities.map((city, i) => {
UIManager.dispatchViewManagerCommand(this.mapViewHandle, 0, [
'marker' + 0,
city.latitude,
city.longitude,
city.city,
city.state,
city.population
]);
});
}
componentDidMount(){
this.mapViewHandle = findNodeHandle(mapRef.current);
DeviceEventEmitter.addListener('onMapReady', this.onMapReady);
}
render() {
return (
<GMap ref={mapRef} style={StyleSheet.absoluteFillObject} />
);
}
}