Skip to content

Commit 17f5458

Browse files
authored
chore: small logic improvements to example app (#371)
Release-As: 0.9.2
1 parent a6fa22e commit 17f5458

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

example/src/controls/navigationControls.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const NavigationControls: React.FC<NavigationControlsProps> = ({
8787
// single destination:
8888
const initWaypoint = async () => {
8989
if (!latitude.trim() || !longitude.trim()) {
90-
Alert.alert('Invalid destination');
90+
Alert.alert('Set lat lng values first');
9191
return;
9292
}
9393
const waypoint: Waypoint = {
@@ -117,19 +117,16 @@ const NavigationControls: React.FC<NavigationControlsProps> = ({
117117
);
118118
};
119119

120-
const initWaypointToCameraLocation = async () => {
120+
const setLocationFromCameraLocation = async () => {
121121
if (getCameraPosition) {
122122
const cameraPosition = await getCameraPosition();
123123
if (cameraPosition) {
124124
onLatChanged(cameraPosition.target.lat.toString());
125125
onLngChanged(cameraPosition.target.lng.toString());
126126
}
127-
await initWaypoint();
128127
}
129128
};
130129

131-
// multi destination:
132-
// set your device (emulator) location to new new york timesquare
133130
const initWaypoints = async () => {
134131
const wp1 = {
135132
placeId: 'ChIJw____96GhYARCVVwg5cT7c0', // Golden gate, SF
@@ -199,7 +196,7 @@ const NavigationControls: React.FC<NavigationControlsProps> = ({
199196

200197
const simulateLocation = () => {
201198
if (!latitude.trim() || !longitude.trim()) {
202-
Alert.alert('Invalid destination');
199+
Alert.alert('Set lat lng values first');
203200
return;
204201
}
205202

@@ -330,6 +327,7 @@ const NavigationControls: React.FC<NavigationControlsProps> = ({
330327

331328
return (
332329
<View>
330+
<Text>Target</Text>
333331
<TextInput
334332
style={styles.input}
335333
onChangeText={onLatChanged}
@@ -346,13 +344,18 @@ const NavigationControls: React.FC<NavigationControlsProps> = ({
346344
placeholderTextColor="#000"
347345
keyboardType="numeric"
348346
/>
349-
<Button title="Dispose navigation" onPress={disposeNavigation} />
350-
<Button title="Single Destination" onPress={initWaypoint} />
351-
<Button title="Multiple Destination" onPress={initWaypoints} />
352347
<Button
353-
title="Set destination from Camera Location"
354-
onPress={initWaypointToCameraLocation}
348+
title="Set target from Camera Location"
349+
onPress={setLocationFromCameraLocation}
350+
/>
351+
<Button
352+
title="Simulate location from target"
353+
onPress={simulateLocation}
355354
/>
355+
<Button title="Set target as Destination" onPress={initWaypoint} />
356+
<View style={styles.controlButtonGap} />
357+
<Button title="Multiple Destination" onPress={initWaypoints} />
358+
<Button title="Dispose navigation" onPress={disposeNavigation} />
356359
<Button
357360
title="Continue to next destination"
358361
onPress={continueToNextDestination}
@@ -362,7 +365,6 @@ const NavigationControls: React.FC<NavigationControlsProps> = ({
362365
<Button title="Stop guidance" onPress={stopGuidance} />
363366
<Button title="Start updating location" onPress={startUpdatingLocation} />
364367
<Button title="Stop updating location" onPress={stopUpdatingLocation} />
365-
<Button title="Simulate location" onPress={simulateLocation} />
366368
<Button title="Start simulation" onPress={startSimulation} />
367369
<Button title="Stop simulation" onPress={stopSimulation} />
368370
<Button title="Pause simulation" onPress={pauseSimulation} />

example/src/styles.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ const styles = StyleSheet.create({
7070
margin: 10,
7171
justifyContent: 'space-evenly',
7272
},
73+
controlButtonGap: {
74+
height: 15,
75+
},
7376
dropdownButtonStyle: {
7477
marginLeft: 12,
7578
width: '50%',

0 commit comments

Comments
 (0)