title: Show my location in map react-native
body: <p>i'm React-Native newbie </p>
  
  <p>I have created a google map but i want when i open my app, it will show my location first. How can i do it ?</p>
  
  <p>Here is my code 
      export default class GoogleMapApi extends Component {
        state = {
          mapRegion: null,
          lastLat: null,
          lastLong: null,
        }</p>
  
  <pre><code>  componentDidMount() {
      this.watchID = navigator.geolocation.watchPosition((position) =&gt; {       
        let region = {
          latitude:       position.coords.latitude,
          longitude:      position.coords.longitude,
          latitudeDelta:  0.00922*1.5,
          longitudeDelta: 0.00421*1.5
        }
        this.onRegionChange(region, region.latitude, region.longitude);
      });
    }
  
    onRegionChange(region, lastLat, lastLong) {
      this.setState({
        mapRegion: region,
        // If there are no new values set use the the current ones
        lastLat: lastLat || this.state.lastLat,
        lastLong: lastLong || this.state.lastLong
      });
    }
  </code></pre>
  
  <p>And </p>
  
  <pre><code>componentWillUnmount() {
          navigator.geolocation.clearWatch(this.watchID);
        }
  
        onMapPress(e) {
          console.log(e.nativeEvent.coordinate.longitude);
          let region = {
            latitude:       e.nativeEvent.coordinate.latitude,
            longitude:      e.nativeEvent.coordinate.longitude,
            latitudeDelta:  0.00922*1.5,
            longitudeDelta: 0.00421*1.5
          }
          this.onRegionChange(region, region.latitude, region.longitude);
        }
  
        render() {
          return (
            &lt;View style={{flex: 1}}&gt;
              &lt;MapView
                style={styles.map}
                region={this.state.mapRegion}
                showsUserLocation={true}
                followUserLocation={true}
                onRegionChange={this.onRegionChange.bind(this)}
                onPress={this.onMapPress.bind(this)}&gt;
                &lt;MapView.Marker
                  coordinate={{
                    latitude: (this.state.lastLat + 0.00050) || -36.82339,
                    longitude: (this.state.lastLong + 0.00050) || -73.03569,
                  }}&gt;
                  &lt;View&gt;
                    &lt;Text style={{color: '#000'}}&gt;
                      { this.state.lastLong } / { this.state.lastLat }
                    &lt;/Text&gt;
                  &lt;/View&gt;
                &lt;/MapView.Marker&gt;
              &lt;/MapView&gt;
            &lt;/View&gt;
          );
        }
      }
  </code></pre>