Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi! I am fetching coordinates from my database every 5 seconds, and my marker is dynamic,This is my render method
console.log('render'+this.state.driverLocation.latitude +' '+this.state.driverLocation.longitude);


    let marker = null;
    marker = <MapView.Marker title='This is you' coordinate={this.state.driverLocation } />;

 return (
      <View style={styles.container}>
        <MapView
          initialRegion={this.state.focusedLocation}
          region={!this.state.locationChosen ? this.state.focusedLocation : null}
          style={styles.map}
          onPress={this.pickLocationHandler}
          ref={ref => this.map = ref}
        >
          {marker}
     


        </MapView>


The log statement in render shows driverLocation changes every 5 sec as it should but the marker stays at the initial position (coordinates given while defining state).

Is there any problem with my code? Do I need to add something? Any help would be appreciated.

What I have tried:

All the values are being assigned correctly and component is rerendering everytime the state changes.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900