Guest User

Untitled

a guest
Oct 18th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. export default class Home extends Component {
  2. state = {
  3. mapRegion: { latitude: 37.78825, longitude: -122.4324, latitudeDelta: 0.0922, longitudeDelta: 0.0421 },
  4. markers: [{key: 1, score: 5, coordinate: {"latitude": 37.8199, "longitude": -122.4783}},
  5. {key: 2, score: 5, coordinate: {"latitude": 37.8059, "longitude": -122.4230}},
  6. {key: 3, score: 3, coordinate: {"latitude": 37.7694, "longitude": -122.4862}},
  7. {key: 4, score: 1, coordinate: {"latitude": 37.7941, "longitude": -122.4078}}]
  8. };
  9.  
  10. _handleMapRegionChange = mapRegion => {
  11. this.setState({ mapRegion });
  12. };
  13.  
  14. render() {
  15. return (
  16. <View style={styles.container}>
  17. <MapView
  18. style={{ alignSelf: 'stretch', flex: 1 }}
  19. region={this.state.mapRegion}
  20. provider={MapView.PROVIDER_GOOGLE}
  21. followsUserLocation={true}
  22. showsMyLocationButton={true}
  23. showsUserLocation={true}
  24. onRegionChange={this._handleMapRegionChange}
  25. >
  26. {this.state.markers.map(marker => {
  27. return (
  28. <Bike key={marker.key}
  29. coordinate={marker.coordinate}
  30. title={"Bike ID: " + marker.key.toString()}
  31. />
  32. );
  33. })}
  34. </MapView>
  35. </View>
  36. )
  37. }
  38. }
Add Comment
Please, Sign In to add comment