Skip to content

Commit 501c3fb

Browse files
frankroweExilz
authored andcommitted
add example for overlay overpress and docs
1 parent 79054ed commit 501c3fb

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

docs/polygon.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
| `lineDashPhase` | `Number` | `0` | (iOS only) The offset (in points) at which to start drawing the dash pattern. Use this property to start drawing a dashed line partway through a segment or gap. For example, a phase value of 6 for the patter 5-2-3-2 would cause drawing to begin in the middle of the first gap.
1616
| `lineDashPattern` | `Array<Number>` | `null` | (iOS only) An array of numbers specifying the dash pattern to use for the path. The array contains one or more numbers that indicate the lengths (measured in points) of the line segments and gaps in the pattern. The values in the array alternate, starting with the first line segment length, followed by the first gap length, followed by the second line segment length, and so on.
1717

18+
## Events
19+
20+
| Event Name | Returns | Notes
21+
|---|---|---|
22+
| `onPress` | | Callback that is called when the user presses on the polygon
1823

1924
## Types
2025

docs/polyline.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
| `lineDashPhase` | `Number` | `0` | (iOS only) The offset (in points) at which to start drawing the dash pattern. Use this property to start drawing a dashed line partway through a segment or gap. For example, a phase value of 6 for the patter 5-2-3-2 would cause drawing to begin in the middle of the first gap.
1515
| `lineDashPattern` | `Array<Number>` | `null` | (iOS only) An array of numbers specifying the dash pattern to use for the path. The array contains one or more numbers that indicate the lengths (measured in points) of the line segments and gaps in the pattern. The values in the array alternate, starting with the first line segment length, followed by the first gap length, followed by the second line segment length, and so on.
1616

17+
## Events
18+
19+
| Event Name | Returns | Notes
20+
|---|---|---|
21+
| `onPress` | | Callback that is called when the user presses on the polyline
1722

1823
## Types
1924

example/examples/EventListener.js

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { PropTypes } from 'react';
2+
import SyntheticEvent from 'react/lib/SyntheticEvent';
23
import {
34
StyleSheet,
45
View,
@@ -65,13 +66,15 @@ class EventListener extends React.Component {
6566

6667
recordEvent(name) {
6768
return e => {
68-
const { events } = this.state;
69-
this.setState({
69+
if (e instanceof SyntheticEvent && typeof e.persist === 'function') {
70+
e.persist();
71+
}
72+
this.setState(prevState => ({
7073
events: [
7174
this.makeEvent(e, name),
72-
...events.slice(0, 10),
75+
...prevState.events.slice(0, 10),
7376
],
74-
});
77+
}));
7578
};
7679
}
7780

@@ -123,6 +126,34 @@ class EventListener extends React.Component {
123126
</View>
124127
</MapView.Callout>
125128
</MapView.Marker>
129+
<MapView.Polygon
130+
fillColor={'rgba(255,0,0,0.3)'}
131+
onPress={this.recordEvent('Polygon::onPress')}
132+
coordinates={[{
133+
latitude: LATITUDE + (LATITUDE_DELTA / 5),
134+
longitude: LONGITUDE + (LONGITUDE_DELTA / 4),
135+
}, {
136+
latitude: LATITUDE + (LATITUDE_DELTA / 3),
137+
longitude: LONGITUDE + (LONGITUDE_DELTA / 4),
138+
}, {
139+
latitude: LATITUDE + (LATITUDE_DELTA / 4),
140+
longitude: LONGITUDE + (LONGITUDE_DELTA / 2),
141+
}]}
142+
/>
143+
<MapView.Polyline
144+
strokeColor={'rgba(255,0,0,1)'}
145+
onPress={this.recordEvent('Polyline::onPress')}
146+
coordinates={[{
147+
latitude: LATITUDE + (LATITUDE_DELTA / 5),
148+
longitude: LONGITUDE - (LONGITUDE_DELTA / 4),
149+
}, {
150+
latitude: LATITUDE + (LATITUDE_DELTA / 3),
151+
longitude: LONGITUDE - (LONGITUDE_DELTA / 4),
152+
}, {
153+
latitude: LATITUDE + (LATITUDE_DELTA / 4),
154+
longitude: LONGITUDE - (LONGITUDE_DELTA / 2),
155+
}]}
156+
/>
126157
</MapView>
127158
<View style={styles.eventList}>
128159
<ScrollView>

0 commit comments

Comments
 (0)