From 9ac9c6819d91ff75cbdcaaaeaca2d59d471e9a11 Mon Sep 17 00:00:00 2001 From: Scott MacLellan Date: Thu, 12 Apr 2018 22:00:05 -0400 Subject: [PATCH] This was handy for testing colours --- screens/overviewMap.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/screens/overviewMap.js b/screens/overviewMap.js index c93e900..a268897 100644 --- a/screens/overviewMap.js +++ b/screens/overviewMap.js @@ -72,6 +72,10 @@ const black = 'rgb(0,0,0)'; const blue = 'rgb(12, 128, 252)'; const backgroundColor = 'rgba(0,0,0,0)'; +let id = 1; +function randomColor() { + return `#${Math.floor(Math.random() * 16777215).toString(16)}`; +} class OverviewMap extends PureComponent { constructor(props) { super(props); @@ -86,6 +90,7 @@ class OverviewMap extends PureComponent { this.state = { ...this.initialRegion, + markers: [], centered: false, isReady: false, tempLocation: null, @@ -94,6 +99,23 @@ class OverviewMap extends PureComponent { }; } + onMapPress = (e) => { + const add = { + coordinate: e.nativeEvent.coordinate, + key: id++, + color: randomColor(), + }; + + console.log(add.color); + + this.setState({ + markers: [ + ...this.state.markers, + add, + ], + }); + } + onMapReady = () => { this.setState({ isReady: true }); @@ -231,7 +253,17 @@ class OverviewMap extends PureComponent { onRegionChangeComplete={this.onRegionChangeComplete} onUserLocationChange={this.onLocationChange} onLongPress={this.onLongPress} + onPress={this.onMapPress} > + + {this.state.markers.map(marker => ( + + ))} + {locations.map(({ location, pinColor }) => (