Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 60 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. import React, { Component } from 'react';
  2. import { View } from 'native-base';
  3. import MapView from 'react-native-maps';
  4. import MapViewDirections from 'react-native-maps-directions';
  5. import styles from './TrackDriverStyles.js';
  6.  
  7. let timer;
  8. const apikey ='AIzaSyCyKO1Ic3A9yty_Lyt8eWtkaQJSV9mNG30';
  9. const driverLocation = driverLocation || {};
  10. export default class MapTrack extends Component {
  11.  
  12.     constructor(props) {
  13.         super(props);
  14.         this.state = {
  15.           posY:driverLocation.coordinate.coordinates[0],
  16.           posX:driverLocation.coordinate.coordinates[1],
  17.           posFinalX:driverLocation.coordinate.coordinates[1],
  18.           posFinalY:driverLocation.coordinate.coordinates[0]
  19.         };
  20.  
  21.        
  22.       }
  23.  
  24. atualizar() {
  25.     if(timer != null) {
  26.       clearInterval(timer);
  27.     }
  28.  
  29.     timer = setInterval(()=>{
  30.       let state = this.state;
  31.  
  32.       if(state.posY < state.posFinalY) {
  33.         state.posY += 2;
  34.       }
  35.       if(state.posY > state.posFinalY) {
  36.         state.posY -= 2;
  37.       }
  38.  
  39.       if(state.posX < state.posFinalX) {
  40.         state.posX += 2;
  41.       }
  42.       if(state.posX > state.posFinalX) {
  43.         state.posX -= 2;
  44.       }
  45.  
  46.       this.setState(state);
  47.     }, 10);
  48.   }
  49.  
  50.   render() {
  51.     return(
  52.         <View style={styles.container}>
  53.            <MapView
  54.                 provider={MapView.PROVIDER_GOOGLE}
  55.                 style={styles.map}
  56.                 region={this.props.region}
  57.                 zoomEnabled={true}
  58.                 minZoomLevel={15}
  59.            >
  60.          
  61.          { showCarMarker &&
  62.              <MapView.Marker
  63.                  coordinate={{latitude:this.state.posY, longitude:this.state.posX}}
  64.                  image={carMarker}
  65.              />
  66.          }
  67.          {bookingInfo &&
  68.             <MapViewDirections
  69.             origin={{latitude:this.props.bookingInfo.pickUp.latitude, longitude:this.props.bookingInfo.pickUp.longitude}}
  70.             destination={{latitude:this.props.bookingInfo.dropOff.latitude, longitude:this.props.bookingInfo.dropOff.longitude}}
  71.             apikey={apikey}
  72.             strokeWidth={4}
  73.             strokeColor="black"
  74.             mode="driving"
  75.             />
  76.          }    
  77.            </MapView>
  78.         </View>
  79.     );
  80.  
  81.     }
  82. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top