javascript - Render multiple marker in react-native-maps -
hye, im new in react native , want ask how render multiple markers in maps.
this code
inside class:-
constructor(props) { super(props); this.state = { coordinate: ([{ latitude: 3.148561, longitude: 101.652778, title: 'hello' }, { latitude: 3.149771, longitude: 101.655449, title: 'hello' } ]), }; }
inside render:-
<mapview style={styles.map} showsuserlocation={true} followuserlocation={true} zoomenabled={true} //annotations={markers} > <mapview.marker coordinate={this.state.coordinate} title={this.state.coordinate.title} /> </mapview> i want render 2 marker inside maps , have no idea how make loop yet in react native render this. try in documentation still not working.
thank in advance :)
coordinate property not constructed properly. -
this.state = { markers: [{ title: 'hello', coordinates: { latitude: 3.148561, longitude: 101.652778 }, }, { title: 'hello', coordinates: { latitude: 3.149771, longitude: 101.655449 }, }] } inside render
<mapview .... > {this.state.markers.map(marker => ( <mapview.marker coordinate={marker.coordinates} title={marker.title} /> ))} </mapview>
Comments
Post a Comment