react-native-steerpath-smart-map 1.29.5 → 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 +35 -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/bin/.project +0 -34
- package/android/bin/.settings/org.eclipse.buildship.core.prefs +0 -13
- package/android/bin/README.md +0 -14
- package/android/bin/build.gradle +0 -59
- package/android/bin/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/bin/gradle/wrapper/gradle-wrapper.properties +0 -6
- package/android/bin/gradlew +0 -172
- package/android/bin/gradlew.bat +0 -84
- package/android/bin/src/main/AndroidManifest.xml +0 -4
- 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,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
|
-
}
|