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.
Files changed (107) hide show
  1. package/.eslintrc.js +66 -0
  2. package/.prettierrc +7 -0
  3. package/CHANGELOG.md +39 -0
  4. package/README.md +7 -0
  5. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNEventKeys.class +0 -0
  6. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartGeofenceManager.class +0 -0
  7. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartLocationManager.class +0 -0
  8. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartMapManager.class +0 -0
  9. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartMapModule.class +0 -0
  10. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartMapPackage.class +0 -0
  11. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartMapPackage.kt +28 -0
  12. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartMapView.class +0 -0
  13. package/android/bin/src/main/java/com/steerpath/rnsmartmap/RNSmartMapViewManager.class +0 -0
  14. package/android/bin/src/main/java/com/steerpath/rnsmartmap/Utils.class +0 -0
  15. package/android/build.gradle +22 -33
  16. package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  17. package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartLocationManager.java +22 -14
  18. package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartMapManager.java +9 -31
  19. package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartMapPackage.java +11 -9
  20. package/android/src/main/java/com/steerpath/rnsmartmap/Utils.java +36 -36
  21. package/ios/RNSmartLocationManager.m +28 -3
  22. package/ios/RNSmartMapManager.m +10 -22
  23. package/lib/commonjs/SmartLocationManager.js +50 -0
  24. package/lib/commonjs/SmartLocationManager.js.map +1 -0
  25. package/lib/commonjs/SmartLocationManager.web.js +11 -0
  26. package/lib/commonjs/SmartLocationManager.web.js.map +1 -0
  27. package/lib/commonjs/SmartMapManager.js +59 -0
  28. package/lib/commonjs/SmartMapManager.js.map +1 -0
  29. package/lib/commonjs/SmartMapManager.web.js +24 -0
  30. package/lib/commonjs/SmartMapManager.web.js.map +1 -0
  31. package/lib/commonjs/index.js +28 -0
  32. package/lib/commonjs/index.js.map +1 -0
  33. package/lib/commonjs/package.json +1 -0
  34. package/lib/module/SmartLocationManager.js +46 -0
  35. package/lib/module/SmartLocationManager.js.map +1 -0
  36. package/lib/module/SmartLocationManager.web.js +7 -0
  37. package/lib/module/SmartLocationManager.web.js.map +1 -0
  38. package/lib/module/SmartMapManager.js +54 -0
  39. package/lib/module/SmartMapManager.js.map +1 -0
  40. package/lib/module/SmartMapManager.web.js +20 -0
  41. package/lib/module/SmartMapManager.web.js.map +1 -0
  42. package/lib/module/index.js +5 -0
  43. package/lib/module/index.js.map +1 -0
  44. package/lib/typescript/SmartLocationManager.d.ts +19 -0
  45. package/lib/typescript/SmartLocationManager.d.ts.map +1 -0
  46. package/{dist → lib/typescript}/SmartLocationManager.web.d.ts +1 -0
  47. package/lib/typescript/SmartLocationManager.web.d.ts.map +1 -0
  48. package/{dist → lib/typescript}/SmartMapManager.d.ts +13 -15
  49. package/lib/typescript/SmartMapManager.d.ts.map +1 -0
  50. package/lib/typescript/SmartMapManager.web.d.ts +8 -0
  51. package/lib/typescript/SmartMapManager.web.d.ts.map +1 -0
  52. package/lib/typescript/index.d.ts +5 -0
  53. package/lib/typescript/index.d.ts.map +1 -0
  54. package/package.json +38 -13
  55. package/react-native-steerpath-smart-map.podspec +15 -12
  56. package/src/SmartLocationManager.ts +25 -9
  57. package/src/SmartMapManager.ts +12 -19
  58. package/src/SmartMapManager.web.ts +3 -24
  59. package/src/index.ts +3 -4
  60. package/tsconfig.json +14 -9
  61. package/.eslintrc.json +0 -81
  62. package/android/src/main/java/com/steerpath/rnsmartmap/RNEventKeys.java +0 -29
  63. package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartGeofenceManager.java +0 -103
  64. package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartMapModule.java +0 -284
  65. package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartMapView.java +0 -470
  66. package/android/src/main/java/com/steerpath/rnsmartmap/RNSmartMapViewManager.java +0 -307
  67. package/dist/SmartGeofenceManager.d.ts +0 -17
  68. package/dist/SmartGeofenceManager.js +0 -61
  69. package/dist/SmartGeofenceManager.web.d.ts +0 -9
  70. package/dist/SmartGeofenceManager.web.js +0 -10
  71. package/dist/SmartLocationManager.d.ts +0 -11
  72. package/dist/SmartLocationManager.js +0 -22
  73. package/dist/SmartLocationManager.web.js +0 -4
  74. package/dist/SmartMapEventManager.web.d.ts +0 -5
  75. package/dist/SmartMapEventManager.web.js +0 -10
  76. package/dist/SmartMapManager.js +0 -53
  77. package/dist/SmartMapManager.web.d.ts +0 -12
  78. package/dist/SmartMapManager.web.js +0 -33
  79. package/dist/SmartMapView.d.ts +0 -3
  80. package/dist/SmartMapView.js +0 -294
  81. package/dist/SmartMapView.web.d.ts +0 -3
  82. package/dist/SmartMapView.web.js +0 -270
  83. package/dist/SmartMapViewProps.d.ts +0 -267
  84. package/dist/SmartMapViewProps.js +0 -76
  85. package/dist/index.d.ts +0 -5
  86. package/dist/index.js +0 -5
  87. package/dist/internalUtils.d.ts +0 -1
  88. package/dist/internalUtils.js +0 -5
  89. package/ios/RCTConvert+SmartMapView.h +0 -35
  90. package/ios/RCTConvert+SmartMapView.m +0 -295
  91. package/ios/RNSmartGeofenceManager.h +0 -24
  92. package/ios/RNSmartGeofenceManager.m +0 -110
  93. package/ios/RNSmartMapUserTaskEventManager.h +0 -19
  94. package/ios/RNSmartMapUserTaskEventManager.m +0 -46
  95. package/ios/RNSmartMapView.h +0 -37
  96. package/ios/RNSmartMapView.m +0 -21
  97. package/ios/RNSmartMapViewManager.h +0 -27
  98. package/ios/RNSmartMapViewManager.m +0 -608
  99. package/package-lock.json +0 -6570
  100. package/src/SmartGeofenceManager.ts +0 -94
  101. package/src/SmartGeofenceManager.web.ts +0 -11
  102. package/src/SmartMapEventManager.web.ts +0 -13
  103. package/src/SmartMapView.tsx +0 -377
  104. package/src/SmartMapView.web.tsx +0 -342
  105. package/src/SmartMapViewProps.ts +0 -338
  106. package/src/internalUtils.ts +0 -5
  107. package/src/typings/steerpath-smart-sdk.d.ts +0 -5
@@ -1,15 +1,14 @@
1
1
  /* eslint-disable prefer-destructuring */
2
2
  import { NativeModules, Platform } from "react-native";
3
- import { ConfigSDK } from './SmartMapViewProps';
3
+ export type ConfigSDK = {
4
+ apiKey: string;
5
+ configFilePath?: string | null;
6
+ configString?: string | null;
7
+ }
4
8
 
5
9
  const RNSmartMapManager = NativeModules.RNSmartMapManager;
6
10
 
7
- interface FetchVersionResponse {
8
- smartSDKVersion: string;
9
- mapboxSDKVersion: string;
10
- }
11
-
12
- export interface LiveConfig {
11
+ export type LiveConfig = {
13
12
  transmit?: {
14
13
  id: string;
15
14
  password: string;
@@ -49,13 +48,6 @@ export const SmartMapManager = {
49
48
  configString,
50
49
  });
51
50
  },
52
- /**
53
- *
54
- * @deprecated Use loginToLive instead.
55
- */
56
- setLiveConfig(config: LiveConfig | null): void {
57
- RNSmartMapManager.setLiveConfig(config);
58
- },
59
51
  /**
60
52
  * Share user location by setting transmit options and show live updates on map by setting receive options.
61
53
  *
@@ -72,10 +64,11 @@ export const SmartMapManager = {
72
64
  logoutFromLive(): void {
73
65
  RNSmartMapManager.logoutFromLive();
74
66
  },
75
- fetchVersions(callback: (versions: FetchVersionResponse) => void) {
76
- RNSmartMapManager.fetchVersions(callback);
67
+ /**
68
+ *
69
+ * @returns Native (iOS/Android) Smart SDK version as a string
70
+ */
71
+ fetchVersion(): Promise<string> {
72
+ return RNSmartMapManager.fetchVersion();
77
73
  },
78
- setLanguage(languageCode: String): void {
79
- RNSmartMapManager.setLanguage(languageCode);
80
- }
81
74
  };
@@ -1,38 +1,17 @@
1
- /* eslint-disable prefer-destructuring */
2
- import { steerpath } from "steerpath-smart-sdk";
3
-
4
- type SmartSDK = {
5
- setLanguage(languageCode: String): void;
6
- }
7
- let smartSDKInstance: SmartSDK = {
8
- setLanguage: () => {}
9
- }
10
-
11
1
  export const SmartMapManager = {
12
- start(apiKey: string, config?: Record<string, unknown> | string): void {
13
- const smartSDK = new steerpath.SmartSDK();
14
- smartSDKInstance = smartSDK;
15
- smartSDK.start(apiKey, config);
2
+ start(): void {
3
+ // No web implementation
16
4
  },
17
- /**
18
- * Not implemented for web. Use start() instead.
19
- */
20
5
  startWithConfig(): void{
21
6
  // No web implementation
22
7
  },
23
- setLanguage(languageCode: String): void {
24
- smartSDKInstance.setLanguage(languageCode);
25
- },
26
- setLiveConfig(): void {
27
- // No web implementation
28
- },
29
8
  loginToLive(): void {
30
9
  // No web implementation
31
10
  },
32
11
  logoutFromLive(): void {
33
12
  // No web implementation
34
13
  },
35
- fetchVersions(): void {
14
+ fetchVersion(): void {
36
15
  // No web implementation
37
16
  }
38
17
  };
package/src/index.ts CHANGED
@@ -1,5 +1,4 @@
1
- export * from './SmartGeofenceManager'
2
1
  export * from './SmartMapManager'
3
- export * from './SmartMapView'
4
- export * from './SmartMapViewProps'
5
- export * from './SmartLocationManager'
2
+ export * from './SmartLocationManager'
3
+ export type { ConfigSDK, LiveConfig } from './SmartMapManager'
4
+ export type { LocationResponse } from './SmartLocationManager'
package/tsconfig.json CHANGED
@@ -1,18 +1,20 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "outDir": "dist",
3
+ "outDir": "lib/typescript",
4
4
  "declaration": true,
5
5
  "allowSyntheticDefaultImports": true,
6
6
  "esModuleInterop": true,
7
7
  "jsx": "react",
8
- "lib": ["es6", "dom", "dom.iterable"],
9
- "moduleResolution": "node",
10
- "typeRoots": ["./src/typings"],
8
+ "lib": [
9
+ "esnext",
10
+ "dom"
11
+ ],
12
+ "moduleResolution": "bundler",
11
13
  "strict": true,
12
- "target": "es5",
14
+ "target": "esnext",
13
15
  "skipLibCheck": true,
14
16
  "forceConsistentCasingInFileNames": true,
15
- "module": "es2015",
17
+ "module": "esnext",
16
18
  "resolveJsonModule": true,
17
19
  "noImplicitAny": false
18
20
  },
@@ -20,7 +22,10 @@
20
22
  "node_modules",
21
23
  "babel.config.js",
22
24
  "metro.config.js",
23
- "jest.config.js"
25
+ "jest.config.js",
26
+ "example"
24
27
  ],
25
- "include": ["src"]
26
- }
28
+ "include": [
29
+ "src"
30
+ ]
31
+ }
package/.eslintrc.json DELETED
@@ -1,81 +0,0 @@
1
- {
2
- "env": {
3
- "browser": true,
4
- "es6": true
5
- },
6
- "extends": [
7
- "eslint:recommended",
8
- "plugin:react/recommended",
9
- "plugin:@typescript-eslint/eslint-recommended",
10
- "plugin:@typescript-eslint/recommended"
11
- ],
12
- "globals": {
13
- "Atomics": "readonly",
14
- "SharedArrayBuffer": "readonly"
15
- },
16
- "parser": "@typescript-eslint/parser",
17
- "parserOptions": {
18
- "ecmaFeatures": {
19
- "jsx": true
20
- },
21
- "ecmaVersion": 11,
22
- "sourceType": "module"
23
- },
24
- "plugins": ["react", "@typescript-eslint"],
25
- "rules": {
26
- "no-plusplus": "off",
27
- "react-hooks/rules-of-hooks": "error",
28
- "react-hooks/exhaustive-deps": "warn",
29
- "react/jsx-filename-extension": "off",
30
- "@typescript-eslint/no-use-before-define": "off",
31
- "@typescript-eslint/explicit-function-return-type": "off",
32
- "no-param-reassign": "off",
33
- "no-use-before-define": "off",
34
- "import/prefer-default-export": "off",
35
- "react/prop-types": "off",
36
- "class-methods-use-this": "off",
37
- "import/no-extraneous-dependencies": "off",
38
- "import/newline-after-import": "off",
39
- "@typescript-eslint/no-var-requires": "off",
40
- "@typescript-eslint/no-unused-vars": "off",
41
- "@typescript-eslint/camelcase": "off",
42
- "react/jsx-indent": "off",
43
- "prefer-const": "off",
44
- "consistent-return": "off",
45
- "@typescript-eslint/semi": "off",
46
- "array-callback-return": "off",
47
- "react/jsx-boolean-value": "off",
48
- "react/jsx-curly-brace-presence": "off",
49
- "react/jsx-curly-newline": "off",
50
- "no-else-return": "off",
51
- "no-inner-declarations": "off",
52
- "no-unused-expressions": "off",
53
- "@typescript-eslint/prefer-interface": "off",
54
- "@typescript-eslint/array-type": "off",
55
- "@typescript-eslint/no-dupe-class-members": "off",
56
- "@typescript-eslint/no-implied-eval": "off",
57
- "@typescript-eslint/no-throw-literal": "off",
58
- "@typescript-eslint/no-unused-expressions": "off",
59
- "spaced-comment": "off",
60
- "no-console": "off",
61
- "no-useless-return": "warn",
62
- "no-prototype-builtins": "warn",
63
- "react/jsx-wrap-multilines": "off",
64
- "react/jsx-props-no-spreading": "off",
65
- "@typescript-eslint/no-explicit-any": "error",
66
- "func-names": "off",
67
- "import/no-cycle": "warn",
68
- "no-nested-ternary": "warn",
69
- "global-require": "warn",
70
- "no-underscore-dangle": "warn",
71
- "react/no-array-index-key": "warn",
72
- "no-lonely-if": "off"
73
- },
74
- "settings": {
75
- "import/resolver": {
76
- "node": {
77
- "extensions": [".js", ".jsx", ".ts", ".tsx"]
78
- }
79
- }
80
- }
81
- }
@@ -1,29 +0,0 @@
1
- package com.steerpath.rnsmartmap;
2
-
3
- public class RNEventKeys {
4
-
5
- // MAP EVENTS
6
- public static final String MAP_LOADED = "onMapLoaded";
7
- public static final String MAP_CLICKED = "onMapClicked";
8
- public static final String USER_FLOOR_CHANGED = "onUserFloorChanged";
9
- public static final String VISIBLE_FLOOR_CHANGED = "onVisibleFloorChanged";
10
- public static final String SEARCH_RESULT_SELECTED = "onSearchResultSelected";
11
- public static final String SEARCH_CATEGORY_SELECTED = "onSearchCategorySelected";
12
-
13
- // USER TASK
14
- public static final String USER_TASK_RESPONSE = "onUserTaskResponse";
15
-
16
- // VIEW STATUS
17
- public static final String VIEW_STATUS_CHANGED = "onViewStatusChanged";
18
- public static final String BOTTOMSHEET_STATE_CHANGED = "onBottomSheetStateChanged";
19
-
20
- // NAVIGATION EVENTS
21
- public static final String NAVIGATION_FAILED = "onNavigationFailed";
22
- public static final String NAVIGATION_ENDED = "onNavigationEnded";
23
- public static final String NAVIGATION_STARTED = "onNavigationStarted";
24
- public static final String NAVIGATION_PREVIEW_APPEARED = "onNavigationPreviewAppeared";
25
- public static final String NAVIGATION_DESTINATION_REACHED = "onNavigationDestinationReached";
26
- public static final String ON_BACK_PRESSED = "onBackPressed";
27
-
28
- public static final String ON_LOCATION_CHANGED = "locationChanged";
29
- }
@@ -1,103 +0,0 @@
1
- package com.steerpath.rnsmartmap;
2
-
3
- import com.facebook.react.bridge.Arguments;
4
- import com.facebook.react.bridge.Callback;
5
- import com.facebook.react.bridge.ReactApplicationContext;
6
- import com.facebook.react.bridge.ReactContext;
7
- import com.facebook.react.bridge.ReactContextBaseJavaModule;
8
- import com.facebook.react.bridge.ReactMethod;
9
- import com.facebook.react.bridge.WritableMap;
10
- import com.facebook.react.modules.core.DeviceEventManagerModule;
11
- import com.steerpath.smart.SmartGeofenceManager;
12
- import com.steerpath.smart.listeners.FenceEventListener;
13
-
14
- import javax.annotation.Nonnull;
15
- import javax.annotation.Nullable;
16
-
17
- public class RNSmartGeofenceManager extends ReactContextBaseJavaModule implements FenceEventListener {
18
-
19
- private final ReactApplicationContext appContext;
20
-
21
- public RNSmartGeofenceManager(@Nonnull ReactApplicationContext reactContext) {
22
- super(reactContext);
23
- this.appContext = reactContext;
24
- }
25
-
26
- @Nonnull
27
- @Override
28
- public String getName() {
29
- return "RNSmartGeofenceManager";
30
- }
31
-
32
- @ReactMethod
33
- public void startListening() {
34
- SmartGeofenceManager.addListener(this);
35
- }
36
-
37
- @ReactMethod
38
- public void stopListening() {
39
- SmartGeofenceManager.removeListener(this);
40
- }
41
-
42
- @ReactMethod
43
- public void addGeofence(String localRef, String buildingRef, Callback callback) {
44
- SmartGeofenceManager.addGeofence(localRef, buildingRef, (String response) -> {
45
- callback.invoke(null, response);
46
- });
47
- }
48
-
49
- @ReactMethod
50
- public void removeGeofence(String localRef, String buildingRef) {
51
- SmartGeofenceManager.removeGeofence(localRef, buildingRef);
52
- }
53
-
54
- @ReactMethod
55
- public void addBeaconfence(String beaconId, Number radiusInM, Number loiteringDelayInMs, Callback callback) {
56
- SmartGeofenceManager.addBeaconfence(beaconId, radiusInM.intValue(), loiteringDelayInMs.intValue(), (String response) -> {
57
- callback.invoke(null, response);
58
- });
59
- }
60
-
61
- @ReactMethod
62
- public void removeBeaconfence(String beaconId) {
63
- SmartGeofenceManager.removeBeaconfence(beaconId);
64
- }
65
-
66
- @Override
67
- public void onGeofenceEnter(String localRef, String buildingRef) {
68
- WritableMap params = Arguments.createMap();
69
- params.putString("localRef", localRef);
70
- params.putString("buildingRef", buildingRef);
71
- sendEvent(appContext, "GeofenceEntered", params);
72
- }
73
-
74
- @Override
75
- public void onGeofenceExit(String localRef, String buildingRef) {
76
- WritableMap params = Arguments.createMap();
77
- params.putString("localRef", localRef);
78
- params.putString("buildingRef", buildingRef);
79
- sendEvent(appContext, "GeofenceExited", params);
80
- }
81
-
82
- @Override
83
- public void onBeaconfenceEnter(String beaconId) {
84
- WritableMap params = Arguments.createMap();
85
- params.putString("beaconId", beaconId);
86
- sendEvent(appContext, "BeaconfenceEntered", params);
87
- }
88
-
89
- @Override
90
- public void onBeaconfenceExit(String beaconId) {
91
- WritableMap params = Arguments.createMap();
92
- params.putString("beaconId", beaconId);
93
- sendEvent(appContext, "BeaconfenceExited", params);
94
- }
95
-
96
- private void sendEvent(ReactContext reactContext,
97
- String eventName,
98
- @Nullable WritableMap params) {
99
- reactContext
100
- .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
101
- .emit(eventName, params);
102
- }
103
- }
@@ -1,284 +0,0 @@
1
- package com.steerpath.rnsmartmap;
2
-
3
- import android.util.Log;
4
-
5
- import com.facebook.react.bridge.Callback;
6
- import com.facebook.react.bridge.ReactApplicationContext;
7
- import com.facebook.react.bridge.ReactContextBaseJavaModule;
8
- import com.facebook.react.bridge.ReactMethod;
9
- import com.facebook.react.bridge.ReadableArray;
10
- import com.facebook.react.bridge.ReadableMap;
11
- import com.facebook.react.bridge.ReadableMapKeySetIterator;
12
- import com.facebook.react.bridge.WritableMap;
13
- import com.facebook.react.bridge.WritableNativeMap;
14
- import com.facebook.react.uimanager.NativeViewHierarchyManager;
15
- import com.facebook.react.uimanager.UIManagerModule;
16
- import com.steerpath.smart.ObjectSource;
17
- import com.steerpath.smart.SmartMapCameraOptions;
18
- import com.steerpath.smart.UserTask;
19
-
20
- import org.json.JSONException;
21
- import org.json.JSONObject;
22
-
23
- import java.util.HashMap;
24
-
25
- import javax.annotation.Nonnull;
26
-
27
- public class RNSmartMapModule extends ReactContextBaseJavaModule {
28
-
29
- public static final String NAME = "RNSmartMapModule";
30
-
31
- public RNSmartMapModule(@Nonnull ReactApplicationContext reactContext) {
32
- super(reactContext);
33
- }
34
-
35
- @Nonnull
36
- @Override
37
- public String getName() {
38
- return NAME;
39
- }
40
-
41
- @ReactMethod
42
- public void getMapObject(final int tag, final ReadableArray args, final Callback callback) {
43
- String localRef = args.getString(0);
44
- String buildingRef = args.getString(1);
45
- String source;
46
-
47
- if (args.getString(2).equals("MARKER")) {
48
- source = ObjectSource.MARKER;
49
- } else {
50
- source = ObjectSource.STATIC;
51
- }
52
-
53
- getUiManager().addUIBlock(nvhm -> {
54
- RNSmartMapView mapView = resolveMapView(nvhm, tag, callback);
55
- if (mapView == null) {
56
- return;
57
- }
58
-
59
- mapView.getMap().getMapObject(localRef, buildingRef, source, (smartMapObject, s) -> {
60
- if (smartMapObject != null) {
61
- callback.invoke(mapView.smartMapObjectToWritableMap(smartMapObject), s);
62
- } else {
63
- callback.invoke(null, s);
64
- }
65
- });
66
- });
67
- }
68
-
69
- @ReactMethod
70
- public void getMapObjectByProperties(final int tag, final ReadableMap map, final Callback callback) {
71
- HashMap<String, Object> properties = new HashMap<>();
72
- ReadableMapKeySetIterator iterator = map.keySetIterator();
73
-
74
- while (iterator.hasNextKey()) {
75
- String key = iterator.nextKey();
76
- switch (map.getType(key)) {
77
- case Number:
78
- properties.put(key, map.getDouble(key));
79
- break;
80
- case Boolean:
81
- properties.put(key, map.getBoolean(key));
82
- break;
83
- case String:
84
- properties.put(key, map.getString(key));
85
- break;
86
- }
87
- }
88
-
89
- getUiManager().addUIBlock(nvhm -> {
90
- RNSmartMapView mapView = resolveMapView(nvhm, tag, callback);
91
- if (mapView == null) {
92
- return;
93
- }
94
-
95
- mapView.getMap().getMapObjectByProperties(properties, (smartMapObject, s) -> {
96
- if (smartMapObject != null) {
97
- callback.invoke(mapView.smartMapObjectToWritableMap(smartMapObject), s);
98
- } else {
99
- callback.invoke(null, s);
100
- }
101
- });
102
- });
103
- }
104
-
105
- @ReactMethod
106
- public void animateCameraToObject(final int tag, final ReadableArray args, final Callback callback) {
107
- String localRef = args.getString(0);
108
- String buildingRef = args.getString(1);
109
- double zoom = args.getDouble(2);
110
-
111
- getUiManager().addUIBlock(nvhm -> {
112
- RNSmartMapView mapView = resolveMapView(nvhm, tag, callback);
113
- if (mapView == null) {
114
- return;
115
- }
116
-
117
- mapView.getMap().animateCameraToObject(localRef, buildingRef, zoom, callback::invoke);
118
- });
119
- }
120
-
121
- @ReactMethod
122
- public void animateCameraToBuildingRef(final int tag, final ReadableArray args, final Callback callback) {
123
- String buildingRef = args.getString(0);
124
-
125
- getUiManager().addUIBlock(nvhm -> {
126
- RNSmartMapView mapView = resolveMapView(nvhm, tag, callback);
127
- if (mapView == null) {
128
- return;
129
- }
130
-
131
- mapView.getMap().animateCameraToBuildingRef(buildingRef, callback::invoke);
132
- });
133
- }
134
-
135
- @ReactMethod
136
- public void setCameraToObject(final int tag, final ReadableArray args, final Callback callback) {
137
- String localRef = args.getString(0);
138
- String buildingRef = args.getString(1);
139
- double zoom = args.getDouble(2);
140
-
141
- getUiManager().addUIBlock(nvhm -> {
142
- RNSmartMapView mapView = resolveMapView(nvhm, tag, callback);
143
- if (mapView == null) {
144
- return;
145
- }
146
-
147
- mapView.getMap().setCameraToObject(localRef, buildingRef, zoom, callback::invoke);
148
- });
149
- }
150
-
151
- @ReactMethod
152
- public void setCameraToBuildingRef(final int tag, final ReadableArray args, final Callback callback) {
153
- String buildingRef = args.getString(0);
154
-
155
- getUiManager().addUIBlock(nvhm -> {
156
- RNSmartMapView mapView = resolveMapView(nvhm, tag, callback);
157
- if (mapView == null) {
158
- return;
159
- }
160
-
161
- mapView.getMap().setCameraToBuildingRef(buildingRef, callback::invoke);
162
- });
163
- }
164
-
165
- @ReactMethod
166
- public void getCurrentUserTask(final int tag, final Callback callback) {
167
- getUiManager().addUIBlock(nvhm -> {
168
- RNSmartMapView mapView = resolveMapView(nvhm, tag, callback);
169
- if (mapView == null) {
170
- return;
171
- }
172
-
173
- UserTask userTask = mapView.getMap().getCurrentUserTask();
174
-
175
- if (userTask == null) {
176
- callback.invoke("No active user task available");
177
- } else {
178
- // TODO: userTask does not have any getters and I cannot return it to JavaScript
179
- // side
180
- callback.invoke(mapView.getMap().getCurrentUserTask());
181
- }
182
- });
183
- }
184
-
185
- @ReactMethod
186
- public void getSmartMapCameraOptions(final int tag, final Callback callback) {
187
- getUiManager().addUIBlock(nvhm -> {
188
- RNSmartMapView mapView = resolveMapView(nvhm, tag, callback);
189
- if (mapView == null) {
190
- return;
191
- }
192
-
193
- SmartMapCameraOptions opts = mapView.getMap().getSmartMapCameraOptions();
194
- WritableMap map = new WritableNativeMap();
195
- map.putDouble("latitude", opts.getLatitude());
196
- map.putDouble("longitude", opts.getLongitude());
197
- map.putDouble("bearing", opts.getBearing());
198
- map.putDouble("pitch", opts.getTilt());
199
- map.putDouble("zoomLevel", opts.getZoomLevel());
200
- callback.invoke(map);
201
- });
202
- }
203
-
204
- @ReactMethod
205
- public void getWidgetPadding(final int tag, final Callback callback) {
206
- getUiManager().addUIBlock(nvhm -> {
207
- RNSmartMapView mapView = resolveMapView(nvhm, tag, callback);
208
- if (mapView == null) {
209
- return;
210
- }
211
-
212
- int[] padding = mapView.getMap().getWidgetPadding();
213
- WritableMap map = new WritableNativeMap();
214
- map.putInt("left", padding[0]);
215
- map.putInt("top", padding[1]);
216
- map.putInt("right", padding[2]);
217
- map.putInt("bottom", padding[3]);
218
-
219
- callback.invoke(map);
220
- });
221
- }
222
-
223
- @ReactMethod
224
- public void onBackPressed(final int tag, final Callback callback) {
225
- getUiManager().addUIBlock(nvhm -> {
226
- RNSmartMapView mapView = resolveMapView(nvhm, tag, callback);
227
- if (mapView == null) {
228
- return;
229
- }
230
-
231
- if (mapView.getMap() != null) {
232
- boolean onBackPressed = mapView.getMap().onBackPressed();
233
- callback.invoke(onBackPressed);
234
- } else {
235
- Log.e("ERROR", "Could not complete method call, SmartMap is null");
236
- }
237
- });
238
- }
239
-
240
- @ReactMethod
241
- public void setGeoJson(final int tag, final ReadableArray args, final Callback callback) {
242
- getUiManager().addUIBlock(nvhm -> {
243
- RNSmartMapView mapView = resolveMapView(nvhm, tag, callback);
244
- if (mapView == null) {
245
- return;
246
- }
247
-
248
- if (mapView.getMap() != null) {
249
- String sourceId = args.getString(0);
250
- ReadableMap geoJsonMap = args.getMap(1);
251
- JSONObject geoJson = null;
252
- if (geoJsonMap != null) {
253
- try {
254
- geoJson = Utils.convertMapToJson(geoJsonMap);
255
- } catch (JSONException e) {
256
- e.printStackTrace();
257
- }
258
- }
259
-
260
- mapView.getMap().setGeoJson(sourceId, geoJson, callback::invoke);
261
- }
262
- });
263
- }
264
-
265
- private UIManagerModule getUiManager() {
266
- final ReactApplicationContext context = getReactApplicationContext();
267
- return context.getNativeModule(UIManagerModule.class);
268
- }
269
-
270
- private RNSmartMapView resolveMapView(NativeViewHierarchyManager nvhm, final int tag, final Callback callback) {
271
- RNSmartMapView mapView = (RNSmartMapView) nvhm.resolveView(tag);
272
- if (mapView == null) {
273
- callback.invoke("RNSmartMapView not found");
274
- return null;
275
- }
276
-
277
- if (mapView.getMap() == null) {
278
- callback.invoke("RNSmartMapView.smartMapFragment is not valid");
279
- return null;
280
- }
281
-
282
- return mapView;
283
- }
284
- }