-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
167 lines (93 loc) · 4.56 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import React, { useEffect, useRef } from 'react';
import {
PixelRatio,
StyleSheet,
Text,
TextInput,
TouchableOpacity,
UIManager,
View,
findNodeHandle,
} from 'react-native';
import MyViewManager from 'react-native-tpl-maps-view';
import { AddMarker, CameraCallback, SetCameraAnimation, SetPolyLine, AddCustomMarker } from 'react-native-tpl-maps-view'
import { Platform } from 'react-native';
import { DeviceEventEmitter } from 'react-native';
import { NativeModules , NativeEventEmitter } from "react-native"
import {useWindowDimensions} from 'react-native';
const createFragment = (viewId: any) =>
UIManager.dispatchViewManagerCommand(
viewId,
// we are calling the 'create' command
"1", [viewId]
);
const App = () => {
const ref = useRef(null);
if (Platform.OS === 'android') {
useEffect(() => {
const viewId = findNodeHandle(ref.current);
createFragment(viewId);
const YourModuleEvents = new NativeEventEmitter(NativeModules.MyModule);
YourModuleEvents.addListener('onReady', (string) => {
if(string === "MapReady"){
_SetCameraAnimation()
}else{
console.log('Received string from Android:', string);
}
});
}, []);
}else{
}
const windowWidth = useWindowDimensions().width;
const windowHeight = useWindowDimensions().height;
return (
<View style={{marginTop: 40 , flex: 1 , flexDirection: 'row'}}>
<Text style={{fontSize: 20 , color: '#000' , marginLeft: 100, alignItems: 'flex-start' , alignSelf: 'flex-start', justifyContent: 'flex-start' , alignContent: 'flex-start' , position: 'absolute'}}onPress={_SetPolyLine}>dadasd</Text>
<MyViewManager
ref={ref}
customWidth = {PixelRatio.getPixelSizeForLayoutSize(windowWidth)}
customHeight = {PixelRatio.getPixelSizeForLayoutSize(windowHeight/1.1)}
/>
<View style={{alignItems: 'flex-start' , alignSelf: 'flex-start', justifyContent: 'flex-start' , alignContent: 'flex-start' , position: 'absolute'}}>
<View style={{
flexDirection: 'column',
alignItems: 'center',
}}>
<Text style={{fontSize: 20 , color: '#000' , margin: 10 , alignItems: 'flex-start' , alignSelf: 'flex-start', justifyContent: 'flex-start' , alignContent: 'flex-start'}} onPress={_SetCameraAnimation}>Zoom on Loc</Text>
<Text style={{fontSize: 20 , color: '#ed0707', margin: 10 , alignItems: 'flex-start' , alignSelf: 'flex-start', justifyContent: 'flex-start' , alignContent: 'flex-start'}} onPress={_AddMarker}>Add Marker on Loc</Text>
<Text style={{fontSize: 20 , color: '#ed0707', margin: 10 , alignItems: 'flex-start' , alignSelf: 'flex-start', justifyContent: 'flex-start' , alignContent: 'flex-start'}} onPress={_AddMarkerRider}>Add Rider Marker on Loc</Text>
<Text style={{fontSize: 20 , color: '#ed0707', margin: 10 , alignItems: 'flex-start' , alignSelf: 'flex-start', justifyContent: 'flex-start' , alignContent: 'flex-start'}} onPress={_AddMarkerOther}>Add Customer Marker on Loc</Text>
<Text style={{fontSize: 20 , color: '#34ff30' , margin: 10 , alignItems: 'flex-start' , alignSelf: 'flex-start', justifyContent: 'flex-start' , alignContent: 'flex-start'}}onPress={_CameraCallback}>Get Lat Long on Camera Move</Text>
</View>
</View>
<Text style={{fontSize: 20 , color: '#FFF' , marginLeft: 100, alignItems: 'flex-end' , alignSelf: 'flex-end', justifyContent: 'flex-end' , alignContent: 'flex-end' , position: 'absolute'}}onPress={_SetPolyLine}>Footer Add Polyline</Text>
</View>
);
};
const _SetCameraAnimation = () => {
// Use the same format for passing arguments.
SetCameraAnimation("67.125973;24.820649", "15")
}
const _AddMarker = () => {
// Use the same format for passing arguments.
AddMarker("67.125973;24.820649")
}
const _AddMarkerRider = () => {
// Use the same format for passing arguments.
AddCustomMarker("67.124412;24.820288;rider;60;60")
}
const _AddMarkerOther = () => {
// Use the same format for passing arguments.
AddCustomMarker("67.083189;24.866864;branch;60;60;branch1;Test Decription")
}
const _CameraCallback = () => {
CameraCallback()
}
const _SetPolyLine = () => {
// Use the same format for passing arguments.
//Multiple Destination LatLng
const destinationTasks = ['24.866864;67.083189'];
// Passing Current Location LatLng , Desitnation LatLng and ApiKey
SetPolyLine("24.820288;67.124412" , destinationTasks, "")
}
export default App;