Skip to content

Instantly share code, notes, and snippets.

@princessjanf
Created December 4, 2017 15:18
Show Gist options
  • Save princessjanf/d87a9ad9af609c1a32a70ae205763b87 to your computer and use it in GitHub Desktop.
Save princessjanf/d87a9ad9af609c1a32a70ae205763b87 to your computer and use it in GitHub Desktop.
View that shows condition for showing current location marker
render() {
return (
<MapView style={styles.map} initialRegion={{
latitude:-6.270565,
longitude:106.759550,
latitudeDelta: 1,
longitudeDelta: 1
}}>
{!!this.state.latitude && !!this.state.longitude && <MapView.Marker
coordinate={{"latitude":this.state.latitude,"longitude":this.state.longitude}}
title={"Your Location"}
/>}
</MapView>
);
}
const styles = StyleSheet.create({
map: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment