react-native-steerpath-smart-map 1.29.4 → 2.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +66 -0
- package/.prettierrc +7 -0
- package/CHANGELOG.md +39 -0
- package/README.md +7 -0
- package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNEventKeys.class +0 -0
- package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartGeofenceManager.class +0 -0
- package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartLocationManager.class +0 -0
- package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartMapManager.class +0 -0
- package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartMapModule.class +0 -0
- package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartMapPackage.class +0 -0
- package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartMapPackage.kt +28 -0
- package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartMapView.class +0 -0
- package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartMapViewManager.class +0 -0
- package/android/bin/src/main/java/com/steerpath/rnsmartmap/Utils.class +0 -0
- package/android/build.gradle +22 -33
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartLocationManager.java +22 -14
- package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartMapManager.java +9 -31
- package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartMapPackage.java +11 -9
- package/android/src/main/java/com/steerpath/rnsmartmap/Utils.java +36 -36
- package/ios/RNSmartLocationManager.m +28 -3
- package/ios/RNSmartMapManager.m +10 -22
- package/lib/commonjs/SmartLocationManager.js +50 -0
- package/lib/commonjs/SmartLocationManager.js.map +1 -0
- package/lib/commonjs/SmartLocationManager.web.js +11 -0
- package/lib/commonjs/SmartLocationManager.web.js.map +1 -0
- package/lib/commonjs/SmartMapManager.js +59 -0
- package/lib/commonjs/SmartMapManager.js.map +1 -0
- package/lib/commonjs/SmartMapManager.web.js +24 -0
- package/lib/commonjs/SmartMapManager.web.js.map +1 -0
- package/lib/commonjs/index.js +28 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/module/SmartLocationManager.js +46 -0
- package/lib/module/SmartLocationManager.js.map +1 -0
- package/lib/module/SmartLocationManager.web.js +7 -0
- package/lib/module/SmartLocationManager.web.js.map +1 -0
- package/lib/module/SmartMapManager.js +54 -0
- package/lib/module/SmartMapManager.js.map +1 -0
- package/lib/module/SmartMapManager.web.js +20 -0
- package/lib/module/SmartMapManager.web.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/SmartLocationManager.d.ts +19 -0
- package/lib/typescript/SmartLocationManager.d.ts.map +1 -0
- package/{dist → lib/typescript}/SmartLocationManager.web.d.ts +1 -0
- package/lib/typescript/SmartLocationManager.web.d.ts.map +1 -0
- package/{dist → lib/typescript}/SmartMapManager.d.ts +13 -15
- package/lib/typescript/SmartMapManager.d.ts.map +1 -0
- package/lib/typescript/SmartMapManager.web.d.ts +8 -0
- package/lib/typescript/SmartMapManager.web.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +5 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/package.json +38 -13
- package/react-native-steerpath-smart-map.podspec +15 -12
- package/src/SmartLocationManager.ts +25 -9
- package/src/SmartMapManager.ts +12 -19
- package/src/SmartMapManager.web.ts +3 -24
- package/src/index.ts +3 -4
- package/tsconfig.json +14 -9
- package/.eslintrc.json +0 -81
- package/android/src/main/java/com/steerpath/rnsmartmap/RNEventKeys.java +0 -29
- package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartGeofenceManager.java +0 -103
- package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartMapModule.java +0 -284
- package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartMapView.java +0 -470
- package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartMapViewManager.java +0 -307
- package/dist/SmartGeofenceManager.d.ts +0 -17
- package/dist/SmartGeofenceManager.js +0 -61
- package/dist/SmartGeofenceManager.web.d.ts +0 -9
- package/dist/SmartGeofenceManager.web.js +0 -10
- package/dist/SmartLocationManager.d.ts +0 -11
- package/dist/SmartLocationManager.js +0 -22
- package/dist/SmartLocationManager.web.js +0 -4
- package/dist/SmartMapEventManager.web.d.ts +0 -5
- package/dist/SmartMapEventManager.web.js +0 -10
- package/dist/SmartMapManager.js +0 -53
- package/dist/SmartMapManager.web.d.ts +0 -12
- package/dist/SmartMapManager.web.js +0 -33
- package/dist/SmartMapView.d.ts +0 -3
- package/dist/SmartMapView.js +0 -294
- package/dist/SmartMapView.web.d.ts +0 -3
- package/dist/SmartMapView.web.js +0 -270
- package/dist/SmartMapViewProps.d.ts +0 -267
- package/dist/SmartMapViewProps.js +0 -76
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -5
- package/dist/internalUtils.d.ts +0 -1
- package/dist/internalUtils.js +0 -5
- package/ios/RCTConvert+SmartMapView.h +0 -35
- package/ios/RCTConvert+SmartMapView.m +0 -295
- package/ios/RNSmartGeofenceManager.h +0 -24
- package/ios/RNSmartGeofenceManager.m +0 -110
- package/ios/RNSmartMapUserTaskEventManager.h +0 -19
- package/ios/RNSmartMapUserTaskEventManager.m +0 -46
- package/ios/RNSmartMapView.h +0 -37
- package/ios/RNSmartMapView.m +0 -21
- package/ios/RNSmartMapViewManager.h +0 -27
- package/ios/RNSmartMapViewManager.m +0 -608
- package/package-lock.json +0 -6570
- package/src/SmartGeofenceManager.ts +0 -94
- package/src/SmartGeofenceManager.web.ts +0 -11
- package/src/SmartMapEventManager.web.ts +0 -13
- package/src/SmartMapView.tsx +0 -377
- package/src/SmartMapView.web.tsx +0 -342
- package/src/SmartMapViewProps.ts +0 -338
- package/src/internalUtils.ts +0 -5
- package/src/typings/steerpath-smart-sdk.d.ts +0 -5
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/* eslint-disable prefer-destructuring */
|
|
2
|
-
import { NativeModules, NativeEventEmitter } from "react-native";
|
|
3
|
-
import { SmartGeofenceResponse } from "./SmartMapViewProps";
|
|
4
|
-
|
|
5
|
-
export enum SmartGeofenceEvent {
|
|
6
|
-
GEOFENCE_ENTERED = "GeofenceEntered",
|
|
7
|
-
GEOFENCE_EXITED = "GeofenceExited",
|
|
8
|
-
BEACONFENCE_ENTERED = "BeaconfenceEntered",
|
|
9
|
-
BEACONFENCE_EXITED = "BeaconfenceExited",
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const POSSIBLE_EVENTS: SmartGeofenceEvent[] = [
|
|
13
|
-
SmartGeofenceEvent.GEOFENCE_ENTERED,
|
|
14
|
-
SmartGeofenceEvent.GEOFENCE_EXITED,
|
|
15
|
-
SmartGeofenceEvent.BEACONFENCE_ENTERED,
|
|
16
|
-
SmartGeofenceEvent.BEACONFENCE_EXITED,
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
const RNSmartGeofenceManager = NativeModules.RNSmartGeofenceManager;
|
|
20
|
-
|
|
21
|
-
const smartGeofenceManagerEmitter = new NativeEventEmitter(
|
|
22
|
-
RNSmartGeofenceManager
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
function createSmartGeofenceManager() {
|
|
26
|
-
let eventListenerRegistered = false;
|
|
27
|
-
return {
|
|
28
|
-
addGeofence(
|
|
29
|
-
localRef: string,
|
|
30
|
-
buildingRef: string,
|
|
31
|
-
callback: (error: Error, response: SmartGeofenceResponse) => void
|
|
32
|
-
) {
|
|
33
|
-
RNSmartGeofenceManager.addGeofence(localRef, buildingRef, callback);
|
|
34
|
-
},
|
|
35
|
-
removeGeofence(localRef: string, buildingRef: string) {
|
|
36
|
-
RNSmartGeofenceManager.removeGeofence(localRef, buildingRef);
|
|
37
|
-
},
|
|
38
|
-
addBeaconfence(
|
|
39
|
-
beaconId: string,
|
|
40
|
-
radius: number,
|
|
41
|
-
loiteringDelay: number,
|
|
42
|
-
callback: (error: Error, response: SmartGeofenceResponse) => void
|
|
43
|
-
) {
|
|
44
|
-
RNSmartGeofenceManager.addBeaconfence(
|
|
45
|
-
beaconId,
|
|
46
|
-
radius,
|
|
47
|
-
loiteringDelay,
|
|
48
|
-
callback
|
|
49
|
-
);
|
|
50
|
-
},
|
|
51
|
-
removeBeaconfence(beaconId: string) {
|
|
52
|
-
RNSmartGeofenceManager.removeBeaconfence(beaconId);
|
|
53
|
-
},
|
|
54
|
-
startListening() {
|
|
55
|
-
RNSmartGeofenceManager.startListening();
|
|
56
|
-
},
|
|
57
|
-
stopListening() {
|
|
58
|
-
RNSmartGeofenceManager.stopListening();
|
|
59
|
-
},
|
|
60
|
-
addListener(
|
|
61
|
-
listener: (
|
|
62
|
-
eventName: SmartGeofenceEvent,
|
|
63
|
-
data: Record<string, string>
|
|
64
|
-
) => void
|
|
65
|
-
) {
|
|
66
|
-
if (!eventListenerRegistered) {
|
|
67
|
-
RNSmartGeofenceManager.startListening();
|
|
68
|
-
eventListenerRegistered = true;
|
|
69
|
-
}
|
|
70
|
-
POSSIBLE_EVENTS.forEach((eventName) => {
|
|
71
|
-
smartGeofenceManagerEmitter.addListener(eventName, (payload) => {
|
|
72
|
-
listener(eventName, payload);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
},
|
|
76
|
-
removeListener(
|
|
77
|
-
listener: (
|
|
78
|
-
eventName: SmartGeofenceEvent,
|
|
79
|
-
data: Record<string, string>
|
|
80
|
-
) => void
|
|
81
|
-
) {
|
|
82
|
-
RNSmartGeofenceManager.stopListening();
|
|
83
|
-
eventListenerRegistered = false;
|
|
84
|
-
|
|
85
|
-
POSSIBLE_EVENTS.forEach((eventName) => {
|
|
86
|
-
smartGeofenceManagerEmitter.removeListener(eventName, (payload) => {
|
|
87
|
-
listener(eventName, payload);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export const SmartGeofenceManager = createSmartGeofenceManager();
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/* eslint-disable prefer-destructuring */
|
|
2
|
-
import { SmartMapEvent } from "./SmartMapViewProps";
|
|
3
|
-
import {NativeEventEmitter } from "react-native";
|
|
4
|
-
|
|
5
|
-
const SmartMapEventManagerEmitter = new NativeEventEmitter();
|
|
6
|
-
export const SmartMapEventManager = {
|
|
7
|
-
addListener(eventName: SmartMapEvent, listener: (data: any) => void) {
|
|
8
|
-
SmartMapEventManagerEmitter.addListener(eventName, listener);
|
|
9
|
-
},
|
|
10
|
-
removeListener(eventName: SmartMapEvent, listener: (data: any) => void) {
|
|
11
|
-
SmartMapEventManagerEmitter.removeListener(eventName, listener);
|
|
12
|
-
}
|
|
13
|
-
};
|
package/src/SmartMapView.tsx
DELETED
|
@@ -1,377 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-redeclare */
|
|
2
|
-
/* eslint-disable prefer-destructuring */
|
|
3
|
-
import React, { useImperativeHandle, forwardRef, useRef } from "react";
|
|
4
|
-
import {
|
|
5
|
-
requireNativeComponent,
|
|
6
|
-
NativeModules,
|
|
7
|
-
findNodeHandle,
|
|
8
|
-
Platform,
|
|
9
|
-
View,
|
|
10
|
-
PixelRatio,
|
|
11
|
-
} from "react-native";
|
|
12
|
-
import { convertNativePixelToDp } from "./internalUtils";
|
|
13
|
-
import { SmartMapViewProps, SmartMapViewMethods } from "./SmartMapViewProps";
|
|
14
|
-
|
|
15
|
-
const NATIVE_VIEW_NAME = "RNSmartMapView";
|
|
16
|
-
|
|
17
|
-
function runCommand<ArgsT extends Array<unknown>>(
|
|
18
|
-
handler: typeof RNSmartMapView | null,
|
|
19
|
-
name: string,
|
|
20
|
-
args: ArgsT
|
|
21
|
-
) {
|
|
22
|
-
if (Platform.OS === "ios") {
|
|
23
|
-
return NativeModules[NATIVE_VIEW_NAME][name](
|
|
24
|
-
findNodeHandle(handler),
|
|
25
|
-
...args
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
return NativeModules.UIManager.dispatchViewManagerCommand(
|
|
29
|
-
findNodeHandle(handler),
|
|
30
|
-
NativeModules.UIManager.getViewManagerConfig(NATIVE_VIEW_NAME).Commands[
|
|
31
|
-
name
|
|
32
|
-
],
|
|
33
|
-
args
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
export const SmartMapView = forwardRef<SmartMapViewMethods, SmartMapViewProps>(
|
|
37
|
-
function _SmartMapViewFC(props, ref) {
|
|
38
|
-
const smartMapRef = useRef<typeof RNSmartMapView>(null);
|
|
39
|
-
|
|
40
|
-
useImperativeHandle(ref, () => ({
|
|
41
|
-
setMapMode(mapMode) {
|
|
42
|
-
runCommand(smartMapRef.current, "setMapMode", [mapMode]);
|
|
43
|
-
},
|
|
44
|
-
addMarker(smartMapObj, layout, iconName, textColor, textHaloColor) {
|
|
45
|
-
runCommand(smartMapRef.current, "addMarker", [
|
|
46
|
-
smartMapObj,
|
|
47
|
-
layout,
|
|
48
|
-
iconName || "category_marker",
|
|
49
|
-
textColor,
|
|
50
|
-
textHaloColor,
|
|
51
|
-
]);
|
|
52
|
-
},
|
|
53
|
-
addMarkers(mapObjectsArray, layout, iconName, textColor, textHaloColor) {
|
|
54
|
-
runCommand(smartMapRef.current, "addMarkers", [
|
|
55
|
-
mapObjectsArray,
|
|
56
|
-
layout,
|
|
57
|
-
iconName || "category_marker",
|
|
58
|
-
textColor,
|
|
59
|
-
textHaloColor,
|
|
60
|
-
]);
|
|
61
|
-
},
|
|
62
|
-
animateCamera({
|
|
63
|
-
latitude,
|
|
64
|
-
longitude,
|
|
65
|
-
zoomLevel,
|
|
66
|
-
bearing,
|
|
67
|
-
pitch,
|
|
68
|
-
floorIndex,
|
|
69
|
-
buildingRef,
|
|
70
|
-
}) {
|
|
71
|
-
runCommand(smartMapRef.current, "animateCamera", [
|
|
72
|
-
latitude,
|
|
73
|
-
longitude,
|
|
74
|
-
zoomLevel,
|
|
75
|
-
bearing ?? 0,
|
|
76
|
-
pitch ?? 0,
|
|
77
|
-
floorIndex ?? 0,
|
|
78
|
-
buildingRef,
|
|
79
|
-
]);
|
|
80
|
-
},
|
|
81
|
-
animateCameraToBuildingRef(buildingRef, callback) {
|
|
82
|
-
if (Platform.OS == "android") {
|
|
83
|
-
NativeModules.RNSmartMapModule.animateCameraToBuildingRef(
|
|
84
|
-
findNodeHandle(smartMapRef.current),
|
|
85
|
-
[buildingRef],
|
|
86
|
-
callback
|
|
87
|
-
);
|
|
88
|
-
} else {
|
|
89
|
-
runCommand(smartMapRef.current, "animateCameraToBuildingRef", [
|
|
90
|
-
buildingRef,
|
|
91
|
-
callback,
|
|
92
|
-
]);
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
animateCameraToObject(localRef, buildingRef, zoomLevel, callback) {
|
|
96
|
-
if (Platform.OS == "android") {
|
|
97
|
-
NativeModules.RNSmartMapModule.animateCameraToObject(
|
|
98
|
-
findNodeHandle(smartMapRef.current),
|
|
99
|
-
[localRef, buildingRef, zoomLevel],
|
|
100
|
-
callback
|
|
101
|
-
);
|
|
102
|
-
} else {
|
|
103
|
-
runCommand(smartMapRef.current, "animateCameraToObject", [
|
|
104
|
-
localRef,
|
|
105
|
-
buildingRef,
|
|
106
|
-
zoomLevel,
|
|
107
|
-
callback,
|
|
108
|
-
]);
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
cancelCurrentUserTask() {
|
|
112
|
-
runCommand(smartMapRef.current, "cancelCurrentUserTask", []);
|
|
113
|
-
},
|
|
114
|
-
getCurrentUserTask(callback) {
|
|
115
|
-
if (Platform.OS == "android") {
|
|
116
|
-
NativeModules.RNSmartMapModule.getCurrentUserTask(
|
|
117
|
-
findNodeHandle(smartMapRef.current),
|
|
118
|
-
callback
|
|
119
|
-
);
|
|
120
|
-
} else {
|
|
121
|
-
runCommand(smartMapRef.current, "getCurrentUserTask", [callback]);
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
getMapObject(localRef, buildingRef, source, callback) {
|
|
125
|
-
if (Platform.OS == "android") {
|
|
126
|
-
NativeModules.RNSmartMapModule.getMapObject(
|
|
127
|
-
findNodeHandle(smartMapRef.current),
|
|
128
|
-
[localRef, buildingRef, source],
|
|
129
|
-
callback
|
|
130
|
-
);
|
|
131
|
-
} else {
|
|
132
|
-
runCommand(smartMapRef.current, "getMapObject", [
|
|
133
|
-
localRef,
|
|
134
|
-
buildingRef,
|
|
135
|
-
source,
|
|
136
|
-
callback,
|
|
137
|
-
]);
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
getMapObjectByProperties(properties, callback) {
|
|
141
|
-
if (Platform.OS == "android") {
|
|
142
|
-
NativeModules.RNSmartMapModule.getMapObjectByProperties(
|
|
143
|
-
findNodeHandle(smartMapRef.current),
|
|
144
|
-
properties,
|
|
145
|
-
callback
|
|
146
|
-
);
|
|
147
|
-
} else {
|
|
148
|
-
runCommand(smartMapRef.current, "getMapObjectByProperties", [
|
|
149
|
-
properties,
|
|
150
|
-
callback,
|
|
151
|
-
]);
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
removeAllMarkers() {
|
|
155
|
-
runCommand(smartMapRef.current, "removeAllMarkers", []);
|
|
156
|
-
},
|
|
157
|
-
removeMarker(smartMapObj) {
|
|
158
|
-
runCommand(smartMapRef.current, "removeMarker", [smartMapObj]);
|
|
159
|
-
},
|
|
160
|
-
removeMarkers(mapObjectsArray) {
|
|
161
|
-
runCommand(smartMapRef.current, "removeMarkers", [mapObjectsArray]);
|
|
162
|
-
},
|
|
163
|
-
selectMapObject(smartMapObj) {
|
|
164
|
-
runCommand(smartMapRef.current, "selectMapObject", [smartMapObj]);
|
|
165
|
-
},
|
|
166
|
-
setCamera({
|
|
167
|
-
latitude,
|
|
168
|
-
longitude,
|
|
169
|
-
zoomLevel,
|
|
170
|
-
bearing,
|
|
171
|
-
pitch,
|
|
172
|
-
floorIndex,
|
|
173
|
-
buildingRef,
|
|
174
|
-
}) {
|
|
175
|
-
runCommand(smartMapRef.current, "setCamera", [
|
|
176
|
-
latitude,
|
|
177
|
-
longitude,
|
|
178
|
-
zoomLevel,
|
|
179
|
-
bearing ?? 0,
|
|
180
|
-
pitch ?? 0,
|
|
181
|
-
floorIndex ?? 0,
|
|
182
|
-
buildingRef,
|
|
183
|
-
]);
|
|
184
|
-
},
|
|
185
|
-
setCameraToBuildingRef(buildingRef, callback) {
|
|
186
|
-
if (Platform.OS == "android") {
|
|
187
|
-
NativeModules.RNSmartMapModule.setCameraToBuildingRef(
|
|
188
|
-
findNodeHandle(smartMapRef.current),
|
|
189
|
-
[buildingRef],
|
|
190
|
-
callback
|
|
191
|
-
);
|
|
192
|
-
} else {
|
|
193
|
-
runCommand(smartMapRef.current, "setCameraToBuildingRef", [
|
|
194
|
-
buildingRef,
|
|
195
|
-
callback,
|
|
196
|
-
]);
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
setCameraToObject(localRef, buildingRef, zoomLevel, callback) {
|
|
200
|
-
if (Platform.OS == "android") {
|
|
201
|
-
NativeModules.RNSmartMapModule.setCameraToObject(
|
|
202
|
-
findNodeHandle(smartMapRef.current),
|
|
203
|
-
[localRef, buildingRef, zoomLevel],
|
|
204
|
-
callback
|
|
205
|
-
);
|
|
206
|
-
} else {
|
|
207
|
-
runCommand(smartMapRef.current, "setCameraToObject", [
|
|
208
|
-
localRef,
|
|
209
|
-
buildingRef,
|
|
210
|
-
zoomLevel,
|
|
211
|
-
callback,
|
|
212
|
-
]);
|
|
213
|
-
}
|
|
214
|
-
},
|
|
215
|
-
startUserTask(userTask) {
|
|
216
|
-
runCommand(smartMapRef.current, "startUserTask", [userTask]);
|
|
217
|
-
},
|
|
218
|
-
start() {
|
|
219
|
-
if (Platform.OS === "android") {
|
|
220
|
-
runCommand(smartMapRef.current, "start", []);
|
|
221
|
-
}
|
|
222
|
-
},
|
|
223
|
-
stop() {
|
|
224
|
-
if (Platform.OS === "android") {
|
|
225
|
-
runCommand(smartMapRef.current, "stop", []);
|
|
226
|
-
}
|
|
227
|
-
},
|
|
228
|
-
onBackPressed(callback) {
|
|
229
|
-
if (Platform.OS === "android") {
|
|
230
|
-
NativeModules.RNSmartMapModule.onBackPressed(
|
|
231
|
-
findNodeHandle(smartMapRef.current),
|
|
232
|
-
callback
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
},
|
|
236
|
-
getWidgetPadding(callback) {
|
|
237
|
-
function processedCallback(padding: {
|
|
238
|
-
left: number;
|
|
239
|
-
top: number;
|
|
240
|
-
right: number;
|
|
241
|
-
bottom: number;
|
|
242
|
-
}) {
|
|
243
|
-
callback({
|
|
244
|
-
left:
|
|
245
|
-
Platform.OS === "android"
|
|
246
|
-
? convertNativePixelToDp(padding.left)
|
|
247
|
-
: padding.left,
|
|
248
|
-
top:
|
|
249
|
-
Platform.OS === "android"
|
|
250
|
-
? convertNativePixelToDp(padding.top)
|
|
251
|
-
: padding.top,
|
|
252
|
-
right:
|
|
253
|
-
Platform.OS === "android"
|
|
254
|
-
? convertNativePixelToDp(padding.right)
|
|
255
|
-
: padding.right,
|
|
256
|
-
bottom:
|
|
257
|
-
Platform.OS === "android"
|
|
258
|
-
? convertNativePixelToDp(padding.bottom)
|
|
259
|
-
: padding.bottom,
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
if (Platform.OS == "android") {
|
|
263
|
-
NativeModules.RNSmartMapModule.getWidgetPadding(
|
|
264
|
-
findNodeHandle(smartMapRef.current),
|
|
265
|
-
processedCallback
|
|
266
|
-
);
|
|
267
|
-
} else {
|
|
268
|
-
runCommand(smartMapRef.current, "getWidgetPadding", [
|
|
269
|
-
processedCallback,
|
|
270
|
-
]);
|
|
271
|
-
}
|
|
272
|
-
},
|
|
273
|
-
setWidgetPadding(left, top, right, bottom) {
|
|
274
|
-
runCommand(
|
|
275
|
-
smartMapRef.current,
|
|
276
|
-
"setWidgetPadding",
|
|
277
|
-
Platform.OS === "android"
|
|
278
|
-
? [
|
|
279
|
-
PixelRatio.getPixelSizeForLayoutSize(left || 0),
|
|
280
|
-
PixelRatio.getPixelSizeForLayoutSize(top || 0),
|
|
281
|
-
PixelRatio.getPixelSizeForLayoutSize(right || 0),
|
|
282
|
-
PixelRatio.getPixelSizeForLayoutSize(bottom || 0),
|
|
283
|
-
]
|
|
284
|
-
: [left || 0, top || 0, right || 0, bottom || 0]
|
|
285
|
-
);
|
|
286
|
-
},
|
|
287
|
-
setGeoJson(sourceId, geoJson, callback) {
|
|
288
|
-
if (Platform.OS === "android") {
|
|
289
|
-
NativeModules.RNSmartMapModule.setGeoJson(
|
|
290
|
-
findNodeHandle(smartMapRef.current),
|
|
291
|
-
[sourceId, geoJson],
|
|
292
|
-
callback
|
|
293
|
-
);
|
|
294
|
-
} else {
|
|
295
|
-
runCommand(smartMapRef.current, "setGeoJson", [
|
|
296
|
-
sourceId,
|
|
297
|
-
geoJson,
|
|
298
|
-
callback,
|
|
299
|
-
]);
|
|
300
|
-
}
|
|
301
|
-
},
|
|
302
|
-
getSmartMapCameraOptions(callback) {
|
|
303
|
-
if (Platform.OS === 'android') {
|
|
304
|
-
NativeModules.RNSmartMapModule.getSmartMapCameraOptions(
|
|
305
|
-
findNodeHandle(smartMapRef.current),
|
|
306
|
-
callback
|
|
307
|
-
);
|
|
308
|
-
} else {
|
|
309
|
-
runCommand(smartMapRef.current, "getSmartMapCameraOptions", [callback]);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}));
|
|
313
|
-
|
|
314
|
-
return (
|
|
315
|
-
<View style={props.style}>
|
|
316
|
-
<RNSmartMapView
|
|
317
|
-
ref={smartMapRef}
|
|
318
|
-
style={{ flex: 1 }}
|
|
319
|
-
onMapLoaded={() => {
|
|
320
|
-
props.onMapLoaded?.();
|
|
321
|
-
}}
|
|
322
|
-
onUserFloorChanged={(event) => {
|
|
323
|
-
props.onUserFloorChanged?.(event.nativeEvent);
|
|
324
|
-
}}
|
|
325
|
-
onViewStatusChanged={(event) => {
|
|
326
|
-
props.onViewStatusChanged?.(event.nativeEvent);
|
|
327
|
-
}}
|
|
328
|
-
onNavigationFailed={(event) => {
|
|
329
|
-
props.onNavigationFailed?.(event.nativeEvent);
|
|
330
|
-
}}
|
|
331
|
-
onNavigationEnded={() => {
|
|
332
|
-
props.onNavigationEnded?.();
|
|
333
|
-
}}
|
|
334
|
-
onNavigationStarted={() => {
|
|
335
|
-
props.onNavigationStarted?.();
|
|
336
|
-
}}
|
|
337
|
-
onNavigationPreviewAppeared={() => {
|
|
338
|
-
props.onNavigationPreviewAppeared?.();
|
|
339
|
-
}}
|
|
340
|
-
onNavigationDestinationReached={() => {
|
|
341
|
-
props.onNavigationDestinationReached?.();
|
|
342
|
-
}}
|
|
343
|
-
onVisibleFloorChanged={(event) => {
|
|
344
|
-
props.onVisibleFloorChanged?.(event.nativeEvent);
|
|
345
|
-
}}
|
|
346
|
-
onMapClicked={(event) => {
|
|
347
|
-
if (Platform.OS === "ios") {
|
|
348
|
-
// iOS Mapbox SDK return a reversed order of map object compared to web and android sdk, so we reverse to match the behavior
|
|
349
|
-
|
|
350
|
-
props.onMapClicked?.({
|
|
351
|
-
mapObjects: [...event.nativeEvent.mapObjects].reverse(),
|
|
352
|
-
});
|
|
353
|
-
} else {
|
|
354
|
-
props.onMapClicked?.(event.nativeEvent);
|
|
355
|
-
}
|
|
356
|
-
}}
|
|
357
|
-
onUserTaskResponse={(event) => {
|
|
358
|
-
props.onUserTaskResponse?.(event.nativeEvent);
|
|
359
|
-
}}
|
|
360
|
-
onSearchResultSelected={(event) => {
|
|
361
|
-
props.onSearchResultSelected?.(event.nativeEvent);
|
|
362
|
-
}}
|
|
363
|
-
onBottomSheetStateChanged={(event) => {
|
|
364
|
-
props.onBottomSheetStateChanged?.(event.nativeEvent);
|
|
365
|
-
}}
|
|
366
|
-
onSearchCategorySelected={(event) => {
|
|
367
|
-
props.onSearchCategorySelected?.(event.nativeEvent);
|
|
368
|
-
}}
|
|
369
|
-
/>
|
|
370
|
-
</View>
|
|
371
|
-
);
|
|
372
|
-
}
|
|
373
|
-
);
|
|
374
|
-
|
|
375
|
-
// It's tedious to type native props, so we can defer it later
|
|
376
|
-
// Hacky escape from requireNativeComponent as it is quite outdated
|
|
377
|
-
const RNSmartMapView = requireNativeComponent<any>(NATIVE_VIEW_NAME) as any;
|