@mapsindoors/react-native-maps-indoors-mapbox 2.6.1 → 2.6.2
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/android/src/main/java/com/mapsindoorsrn/core/DirectionsRendererModule.java +322 -0
- package/android/src/main/java/com/mapsindoorsrn/core/DirectionsServiceModule.java +166 -0
- package/android/src/main/java/com/mapsindoorsrn/core/MPDisplayRuleModule.java +1699 -0
- package/android/src/main/java/com/mapsindoorsrn/core/MapControlModule.java +761 -0
- package/android/src/main/java/com/mapsindoorsrn/core/MapsIndoorsModule.java +410 -0
- package/android/src/main/java/com/mapsindoorsrn/core/RCMapView.java +16 -0
- package/android/src/main/java/com/mapsindoorsrn/core/README.md +3 -0
- package/android/src/main/java/com/mapsindoorsrn/core/UtilsModule.java +227 -0
- package/android/src/main/java/com/mapsindoorsrn/core/models/BitmapStopIconConfig.java +22 -0
- package/android/src/main/java/com/mapsindoorsrn/core/models/Bounds.java +19 -0
- package/android/src/main/java/com/mapsindoorsrn/core/models/Filter.java +77 -0
- package/android/src/main/java/com/mapsindoorsrn/core/models/Location.java +17 -0
- package/android/src/main/java/com/mapsindoorsrn/core/models/MPCameraPosition.java +34 -0
- package/android/src/main/java/com/mapsindoorsrn/core/models/MPCameraUpdate.java +68 -0
- package/android/src/main/java/com/mapsindoorsrn/core/models/MPError.java +38 -0
- package/android/src/main/java/com/mapsindoorsrn/core/models/PositionProvider.java +46 -0
- package/android/src/main/java/com/mapsindoorsrn/core/models/PositionResult.java +117 -0
- package/android/src/main/java/com/mapsindoorsrn/core/models/Query.java +30 -0
- package/android/src/main/java/com/mapsindoorsrn/core/models/RouteStopIconConfigModel.java +35 -0
- package/ios/core/CameraPosition.swift +15 -0
- package/ios/core/CameraUpdate.swift +19 -0
- package/ios/core/CameraUpdateError.swift +11 -0
- package/ios/core/DirectionsRendererBridge.m +59 -0
- package/ios/core/DirectionsRendererModule.swift +359 -0
- package/ios/core/DirectionsServiceBridge.m +55 -0
- package/ios/core/DirectionsServiceModule.swift +186 -0
- package/ios/core/IconStopUrl.swift +17 -0
- package/ios/core/LabelGraphic.swift +15 -0
- package/ios/core/MPDisplayRuleBridge.m +696 -0
- package/ios/core/MPDisplayRuleModule.swift +1704 -0
- package/ios/core/MapControlBridge.m +213 -0
- package/ios/core/MapControlModule.swift +702 -0
- package/ios/core/MapsIndoorsBridge.m +128 -0
- package/ios/core/MapsIndoorsData.swift +288 -0
- package/ios/core/MapsIndoorsModule.swift +363 -0
- package/ios/core/RCMapView.swift +16 -0
- package/ios/core/README.md +3 -0
- package/ios/core/ReactPositionProvider.swift +27 -0
- package/ios/core/RouteIcon.swift +34 -0
- package/ios/core/UtilsBridge.m +73 -0
- package/ios/core/UtilsModule.swift +182 -0
- package/ios/core/helpers.swift +57 -0
- package/package.json +1 -1
- package/src/core/EventNames.ts +21 -0
- package/src/core/MPAdditionalDetail.ts +102 -0
- package/src/core/MPBadgePosition.ts +12 -0
- package/src/core/MPBounds.ts +155 -0
- package/src/core/MPBuilding.ts +333 -0
- package/src/core/MPBuildingCollection.ts +57 -0
- package/src/core/MPBuildingInfo.ts +63 -0
- package/src/core/MPCameraEvent.ts +17 -0
- package/src/core/MPCameraEventListener.ts +17 -0
- package/src/core/MPCameraPosition.ts +82 -0
- package/src/core/MPCameraUpdate.ts +174 -0
- package/src/core/MPCameraViewFitMode.ts +25 -0
- package/src/core/MPCategory.ts +85 -0
- package/src/core/MPCategoryCollection.ts +62 -0
- package/src/core/MPCollection.ts +59 -0
- package/src/core/MPCollisionHandling.ts +12 -0
- package/src/core/MPDailyOpeningHours.ts +67 -0
- package/src/core/MPDataField.ts +69 -0
- package/src/core/MPDetailType.ts +73 -0
- package/src/core/MPDirectionsRenderer.ts +238 -0
- package/src/core/MPDirectionsService.ts +152 -0
- package/src/core/MPDisplayRule.ts +1823 -0
- package/src/core/MPEntity.ts +60 -0
- package/src/core/MPEntityInfo.ts +28 -0
- package/src/core/MPError.ts +122 -0
- package/src/core/MPFeatureTypes.ts +8 -0
- package/src/core/MPFilter.ts +168 -0
- package/src/core/MPFilterBehavior.ts +115 -0
- package/src/core/MPFloor.ts +170 -0
- package/src/core/MPFloorSelectorInterface.ts +63 -0
- package/src/core/MPGeometry.ts +91 -0
- package/src/core/MPHighlightBehavior.ts +115 -0
- package/src/core/MPHighway.ts +14 -0
- package/src/core/MPIconPlacement.ts +13 -0
- package/src/core/MPIconSize.ts +39 -0
- package/src/core/MPLabelGraphic.ts +24 -0
- package/src/core/MPLabelPosition.ts +12 -0
- package/src/core/MPLabelType.ts +11 -0
- package/src/core/MPLocation.ts +440 -0
- package/src/core/MPLocationPropertyNames.ts +30 -0
- package/src/core/MPLocationSettings.ts +40 -0
- package/src/core/MPLocationType.ts +16 -0
- package/src/core/MPMapConfig.ts +280 -0
- package/src/core/MPMapStyle.ts +57 -0
- package/src/core/MPMultiPolygon.ts +218 -0
- package/src/core/MPOpeningHours.ts +48 -0
- package/src/core/MPPOIType.ts +43 -0
- package/src/core/MPPoint.ts +169 -0
- package/src/core/MPPolygon.ts +219 -0
- package/src/core/MPPositionProviderInterface.ts +45 -0
- package/src/core/MPPositionResultInterface.ts +42 -0
- package/src/core/MPPropertyData.ts +234 -0
- package/src/core/MPQuery.ts +69 -0
- package/src/core/MPRoute.ts +105 -0
- package/src/core/MPRouteCoordinate.ts +95 -0
- package/src/core/MPRouteLeg.ts +158 -0
- package/src/core/MPRouteProperty.ts +83 -0
- package/src/core/MPRouteStep.ts +186 -0
- package/src/core/MPRouteStopIconConfig.ts +82 -0
- package/src/core/MPSelectionBehavior.ts +114 -0
- package/src/core/MPSelectionMode.ts +4 -0
- package/src/core/MPSettings3D.ts +107 -0
- package/src/core/MPSize.ts +21 -0
- package/src/core/MPSolution.ts +189 -0
- package/src/core/MPSolutionConfig.ts +188 -0
- package/src/core/MPSolutionDisplayRule.ts +15 -0
- package/src/core/MPUserRole.ts +60 -0
- package/src/core/MPUserRoleCollection.ts +37 -0
- package/src/core/MPUtils.ts +178 -0
- package/src/core/MPVenue.ts +294 -0
- package/src/core/MPVenueCollection.ts +58 -0
- package/src/core/MPVenueInfo.ts +62 -0
- package/src/core/MPWeeklyOpeningHours.ts +129 -0
- package/src/core/MapControl.ts +961 -0
- package/src/core/MapView.tsx +34 -0
- package/src/core/MapsIndoors.ts +571 -0
- package/src/core/OnBuildingFoundAtCameraTargetListener.ts +17 -0
- package/src/core/OnFloorSelectionChangedListener.ts +17 -0
- package/src/core/OnFloorUpdateListener.ts +16 -0
- package/src/core/OnLegSelectedListener.ts +17 -0
- package/src/core/OnLiveLocationUpdateListener.ts +17 -0
- package/src/core/OnLocationSelectedListener.ts +17 -0
- package/src/core/OnMapClickListener.ts +20 -0
- package/src/core/OnMarkerClickListener.ts +17 -0
- package/src/core/OnMarkerInfoWindowClickListener.ts +17 -0
- package/src/core/OnPositionUpdateListener.ts +17 -0
- package/src/core/OnVenueFoundAtCameraTargetListener.ts +17 -0
- package/src/core/README.md +3 -0
- package/src/core/RouteStopIconConfig.ts +10 -0
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
package com.mapsindoorsrn.core;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Arguments;
|
|
4
|
+
import com.facebook.react.bridge.Promise;
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
6
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
7
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
8
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
9
|
+
import com.google.gson.Gson;
|
|
10
|
+
import com.google.gson.reflect.TypeToken;
|
|
11
|
+
import com.mapsindoors.core.MPBuilding;
|
|
12
|
+
import com.mapsindoors.core.MPBuildingCollection;
|
|
13
|
+
import com.mapsindoors.core.MPCategory;
|
|
14
|
+
import com.mapsindoors.core.MPCategoryCollection;
|
|
15
|
+
import com.mapsindoors.core.MPDataSetCache;
|
|
16
|
+
import com.mapsindoors.core.MPDataSetCacheManager;
|
|
17
|
+
import com.mapsindoors.core.MPDataSetCacheScope;
|
|
18
|
+
import com.mapsindoors.core.MPDataSetManagerStatus;
|
|
19
|
+
import com.mapsindoors.core.MPDisplayRule;
|
|
20
|
+
import com.mapsindoors.core.MPFilter;
|
|
21
|
+
import com.mapsindoors.core.MPLocation;
|
|
22
|
+
import com.mapsindoors.core.MPPoint;
|
|
23
|
+
import com.mapsindoors.core.MPQuery;
|
|
24
|
+
import com.mapsindoors.core.MPSolution;
|
|
25
|
+
import com.mapsindoors.core.MPUserRole;
|
|
26
|
+
import com.mapsindoors.core.MPUserRoleCollection;
|
|
27
|
+
import com.mapsindoors.core.MPVenue;
|
|
28
|
+
import com.mapsindoors.core.MPVenueCollection;
|
|
29
|
+
import com.mapsindoors.core.MapsIndoors;
|
|
30
|
+
import com.mapsindoors.core.errors.MIError;
|
|
31
|
+
import com.mapsindoors.core.models.MPMapStyle;
|
|
32
|
+
import com.mapsindoorsrn.core.models.Filter;
|
|
33
|
+
import com.mapsindoorsrn.core.models.MPError;
|
|
34
|
+
import com.mapsindoorsrn.core.models.PositionProvider;
|
|
35
|
+
import com.mapsindoorsrn.core.models.PositionResult;
|
|
36
|
+
import com.mapsindoorsrn.core.models.Query;
|
|
37
|
+
|
|
38
|
+
import java.util.ArrayList;
|
|
39
|
+
import java.util.Collections;
|
|
40
|
+
import java.util.List;
|
|
41
|
+
|
|
42
|
+
public class MapsIndoorsModule extends ReactContextBaseJavaModule {
|
|
43
|
+
|
|
44
|
+
private final ReactApplicationContext reactContext;
|
|
45
|
+
private final Gson gson = new Gson();
|
|
46
|
+
|
|
47
|
+
private PositionProvider positionProvider;
|
|
48
|
+
|
|
49
|
+
public MapsIndoorsModule(ReactApplicationContext reactContext) {
|
|
50
|
+
super(reactContext);
|
|
51
|
+
this.reactContext = reactContext;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@Override
|
|
55
|
+
public String getName() {
|
|
56
|
+
return "MapsIndoorsModule";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private void reject(Promise promise, MIError error) {
|
|
60
|
+
promise.reject("MapsIndoorsError", gson.toJson(MPError.fromMIError(error)));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@ReactMethod
|
|
64
|
+
public void loadMapsIndoors(String apiKey, ReadableArray optionalStrings, Promise promise) {
|
|
65
|
+
try {
|
|
66
|
+
if (optionalStrings != null) {
|
|
67
|
+
List<String> venueList = new ArrayList<>();
|
|
68
|
+
for (int i = 0; i < optionalStrings.size(); i++) {
|
|
69
|
+
venueList.add(optionalStrings.getString(i));
|
|
70
|
+
}
|
|
71
|
+
MapsIndoors.load(reactContext.getApplicationContext(), apiKey, venueList, miError -> {
|
|
72
|
+
if (miError == null) {
|
|
73
|
+
promise.resolve(null);
|
|
74
|
+
} else {
|
|
75
|
+
reject(promise, miError);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
} else {
|
|
79
|
+
MapsIndoors.load(reactContext.getApplicationContext(), apiKey, miError -> {
|
|
80
|
+
if (miError == null) {
|
|
81
|
+
promise.resolve(null);
|
|
82
|
+
} else {
|
|
83
|
+
reject(promise, miError);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
} catch (Exception e) {
|
|
88
|
+
reject(promise, new MIError(MIError.UNKNOWN_ERROR, e.getMessage()));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@ReactMethod
|
|
93
|
+
public void getDefaultVenue(final Promise promise) {
|
|
94
|
+
MPVenueCollection venues = MapsIndoors.getVenues();
|
|
95
|
+
if (venues != null) {
|
|
96
|
+
MPVenue venue = venues.getDefaultVenue();
|
|
97
|
+
if (venue != null) {
|
|
98
|
+
String venueString = gson.toJson(venue);
|
|
99
|
+
promise.resolve(venueString);
|
|
100
|
+
} else {
|
|
101
|
+
promise.resolve(null);
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
reject(promise, new MIError(MIError.UNKNOWN_ERROR, "Cannot fetch venues, try waiting until MapsIndoors is Ready"));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@ReactMethod
|
|
110
|
+
public void getVenues(final Promise promise) {
|
|
111
|
+
MPVenueCollection venueCollection = MapsIndoors.getVenues();
|
|
112
|
+
if (venueCollection != null) {
|
|
113
|
+
List<MPVenue> venues = venueCollection.getVenues();
|
|
114
|
+
String venuesString = gson.toJson(venues);
|
|
115
|
+
promise.resolve(venuesString);
|
|
116
|
+
} else {
|
|
117
|
+
reject(promise, new MIError(MIError.UNKNOWN_ERROR, "Cannot fetch venues, try waiting until MapsIndoors is Ready"));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
@ReactMethod
|
|
122
|
+
public void getBuildings(final Promise promise) {
|
|
123
|
+
MPBuildingCollection buildingCollection = MapsIndoors.getBuildings();
|
|
124
|
+
if (buildingCollection != null) {
|
|
125
|
+
List<MPBuilding> buildings = buildingCollection.getBuildings();
|
|
126
|
+
String buildingString = gson.toJson(buildings);
|
|
127
|
+
promise.resolve(buildingString);
|
|
128
|
+
} else {
|
|
129
|
+
reject(promise, new MIError(MIError.UNKNOWN_ERROR, "Cannot fetch buildings, try waiting until MapsIndoors is Ready"));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@ReactMethod
|
|
134
|
+
public void getCategories(final Promise promise) {
|
|
135
|
+
MPCategoryCollection categoryCollection = MapsIndoors.getCategories();
|
|
136
|
+
if (categoryCollection != null) {
|
|
137
|
+
List<MPCategory> categories = categoryCollection.getCategories();
|
|
138
|
+
String categoriesString = gson.toJson(categories);
|
|
139
|
+
promise.resolve(categoriesString);
|
|
140
|
+
} else {
|
|
141
|
+
reject(promise, new MIError(MIError.UNKNOWN_ERROR, "Cannot fetch categories, try waiting until MapsIndoors is Ready"));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@ReactMethod
|
|
146
|
+
public void getLocations(final Promise promise) {
|
|
147
|
+
ArrayList<MPLocation> locations = new ArrayList<>(MapsIndoors.getLocations());
|
|
148
|
+
if (!locations.isEmpty()) {
|
|
149
|
+
String locationsString = gson.toJson(locations);
|
|
150
|
+
promise.resolve(locationsString);
|
|
151
|
+
} else {
|
|
152
|
+
reject(promise, new MIError(MIError.UNKNOWN_ERROR, "Cannot fetch categories, try waiting until MapsIndoors is Ready"));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
@ReactMethod
|
|
157
|
+
public void disableEventLogging(boolean disable, final Promise promise) {
|
|
158
|
+
MapsIndoors.disableEventLogging(disable);
|
|
159
|
+
promise.resolve(null);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
@ReactMethod
|
|
163
|
+
public void getApiKey(final Promise promise) {
|
|
164
|
+
promise.resolve(MapsIndoors.getAPIKey());
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
@ReactMethod
|
|
168
|
+
public void getAvailableLanguages(final Promise promise) {
|
|
169
|
+
List<String> languages = MapsIndoors.getAvailableLanguages();
|
|
170
|
+
if (languages != null) {
|
|
171
|
+
ReadableArray array = Arguments.fromList(languages);
|
|
172
|
+
promise.resolve(array);
|
|
173
|
+
} else {
|
|
174
|
+
reject(promise, new MIError(MIError.UNKNOWN_ERROR, "No languages are available, try waiting until MapsIndoors is Ready"));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
@ReactMethod
|
|
179
|
+
public void getDefaultLanguage(final Promise promise) {
|
|
180
|
+
promise.resolve(MapsIndoors.getDefaultLanguage());
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
@ReactMethod
|
|
184
|
+
public void getLanguage(final Promise promise) {
|
|
185
|
+
promise.resolve(MapsIndoors.getLanguage());
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
@ReactMethod
|
|
189
|
+
public void getLocationById(String id, final Promise promise) {
|
|
190
|
+
MPLocation location = MapsIndoors.getLocationById(id);
|
|
191
|
+
if (location != null) {
|
|
192
|
+
String locationString = gson.toJson(location);
|
|
193
|
+
promise.resolve(locationString);
|
|
194
|
+
} else {
|
|
195
|
+
promise.resolve(null);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
@ReactMethod
|
|
200
|
+
public void getLocationsByExternalIds(ReadableArray externalIdArray, final Promise promise) {
|
|
201
|
+
List<String> externalIds = new ArrayList<>();
|
|
202
|
+
for (int i = 0; i < externalIdArray.size(); i++) {
|
|
203
|
+
externalIds.add(externalIdArray.getString(i));
|
|
204
|
+
}
|
|
205
|
+
List<MPLocation> locations = MapsIndoors.getLocationsByExternalIds(externalIds);
|
|
206
|
+
String locationsString = gson.toJson(locations);
|
|
207
|
+
promise.resolve(locationsString);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
@ReactMethod
|
|
211
|
+
public void getMapStyles(final Promise promise) {
|
|
212
|
+
List<MPMapStyle> mapStyles = MapsIndoors.getMapStyles();
|
|
213
|
+
String mapStylesString = gson.toJson(mapStyles);
|
|
214
|
+
promise.resolve(mapStylesString);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
@ReactMethod
|
|
218
|
+
public void getSolution(final Promise promise) {
|
|
219
|
+
MPSolution solution = MapsIndoors.getSolution();
|
|
220
|
+
String solutionString = solution != null ? gson.toJson(solution): null;
|
|
221
|
+
promise.resolve(solutionString);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
@ReactMethod
|
|
225
|
+
public void getLocationsAsync(String query, String filter, final Promise promise) {
|
|
226
|
+
MPQuery mpQuery = gson.fromJson(query, Query.class).toMPQuery();
|
|
227
|
+
MPFilter mpFilter = gson.fromJson(filter, Filter.class).toMPFilter();
|
|
228
|
+
|
|
229
|
+
MapsIndoors.getLocationsAsync(mpQuery, mpFilter, (list, miError) -> {
|
|
230
|
+
if (miError == null) {
|
|
231
|
+
String locationsString = gson.toJson(list);
|
|
232
|
+
promise.resolve(locationsString);
|
|
233
|
+
} else {
|
|
234
|
+
reject(promise, miError);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
@ReactMethod
|
|
240
|
+
public void locationDisplayRuleExists(String locationId, final Promise promise) {
|
|
241
|
+
MPDisplayRule rule = MapsIndoors.getDisplayRule(MapsIndoors.getLocationById(locationId));
|
|
242
|
+
promise.resolve(rule != null);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
@ReactMethod
|
|
246
|
+
public void displayRuleNameExists(String name, final Promise promise) {
|
|
247
|
+
MPDisplayRule displayRule = MapsIndoors.getDisplayRule(name);
|
|
248
|
+
promise.resolve(displayRule != null);
|
|
249
|
+
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
@ReactMethod
|
|
253
|
+
public void setPositionProvider(String positionProviderName, final Promise promise) {
|
|
254
|
+
positionProvider = new PositionProvider(positionProviderName);
|
|
255
|
+
MapsIndoors.setPositionProvider(positionProvider);
|
|
256
|
+
promise.resolve(null);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
@ReactMethod
|
|
260
|
+
public void removePositionProvider(final Promise promise) {
|
|
261
|
+
positionProvider = null;
|
|
262
|
+
MapsIndoors.setPositionProvider(null);
|
|
263
|
+
promise.resolve(null);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
@ReactMethod
|
|
267
|
+
public void onPositionUpdate(String positionString) {
|
|
268
|
+
PositionResult positionResult = gson.fromJson(positionString, PositionResult.class);
|
|
269
|
+
if (positionProvider != null) {
|
|
270
|
+
positionProvider.updatePosition(positionResult);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
@ReactMethod
|
|
275
|
+
public void getUserRoles(final Promise promise) {
|
|
276
|
+
MPUserRoleCollection userRoles = MapsIndoors.getUserRoles();
|
|
277
|
+
if (userRoles != null) {
|
|
278
|
+
String userRolesString = gson.toJson(userRoles.getUserRoles());
|
|
279
|
+
promise.resolve(userRolesString);
|
|
280
|
+
} else {
|
|
281
|
+
reject(promise, new MIError(MIError.UNKNOWN_ERROR, "Cannot fetch userroles, try waiting until MapsIndoors is Ready"));
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
@ReactMethod
|
|
286
|
+
public void checkOfflineDataAvailability(final Promise promise) {
|
|
287
|
+
promise.resolve(MapsIndoors.checkOfflineDataAvailability());
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
@ReactMethod
|
|
291
|
+
public void destroy(final Promise promise) {
|
|
292
|
+
MapsIndoors.destroy();
|
|
293
|
+
promise.resolve(null);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
@ReactMethod
|
|
297
|
+
public void isApiKeyValid(final Promise promise) {
|
|
298
|
+
promise.resolve(MapsIndoors.isAPIKeyValid());
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
@ReactMethod
|
|
302
|
+
public void isInitialized(final Promise promise) {
|
|
303
|
+
promise.resolve(MapsIndoors.isInitialized());
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
@ReactMethod
|
|
307
|
+
public void isReady(final Promise promise) {
|
|
308
|
+
promise.resolve(MapsIndoors.isReady());
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
@ReactMethod
|
|
312
|
+
public void setLanguage(String lang, final Promise promise) {
|
|
313
|
+
promise.resolve(MapsIndoors.setLanguage(lang));
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
@ReactMethod
|
|
317
|
+
public void synchronizeContent(final Promise promise) {
|
|
318
|
+
MapsIndoors.synchronizeContent(miError -> {
|
|
319
|
+
if (miError != null) {
|
|
320
|
+
reject(promise, miError);
|
|
321
|
+
} else {
|
|
322
|
+
promise.resolve(null);
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
@ReactMethod
|
|
328
|
+
public void applyUserRoles(String userRolesString, final Promise promise) {
|
|
329
|
+
List<MPUserRole> userRoles = gson.fromJson(userRolesString, new TypeToken<List<MPUserRole>>() {}.getType());
|
|
330
|
+
MapsIndoors.applyUserRoles(userRoles);
|
|
331
|
+
promise.resolve(null);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
@ReactMethod
|
|
335
|
+
public void getAppliedUserRoles(final Promise promise) {
|
|
336
|
+
List<MPUserRole> userRoles = MapsIndoors.getAppliedUserRoles();
|
|
337
|
+
if (userRoles != null) {
|
|
338
|
+
promise.resolve(gson.toJson(userRoles));
|
|
339
|
+
} else {
|
|
340
|
+
promise.resolve(null);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
@ReactMethod
|
|
345
|
+
public void reverseGeoCode(String pointString, final Promise promise) {
|
|
346
|
+
MPPoint point = gson.fromJson(pointString, MPPoint.class);
|
|
347
|
+
MapsIndoors.reverseGeoCode(point, mpGeoCodeResult -> promise.resolve(gson.toJson(mpGeoCodeResult)));
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
@ReactMethod
|
|
351
|
+
public void addVenuesToSync(ReadableArray venues, Promise promise) {
|
|
352
|
+
try {
|
|
353
|
+
List<String> venueList = new ArrayList<>();
|
|
354
|
+
for (int i = 0; i < venues.size(); i++) {
|
|
355
|
+
venueList.add(venues.getString(i));
|
|
356
|
+
}
|
|
357
|
+
MapsIndoors.addVenuesToSync(venueList);
|
|
358
|
+
promise.resolve(null);
|
|
359
|
+
} catch (Exception e) {
|
|
360
|
+
promise.reject(e);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
@ReactMethod
|
|
365
|
+
public void removeVenuesToSync(ReadableArray venues, Promise promise) {
|
|
366
|
+
try {
|
|
367
|
+
List<String> venueList = new ArrayList<>();
|
|
368
|
+
for (int i = 0; i < venues.size(); i++) {
|
|
369
|
+
venueList.add(venues.getString(i));
|
|
370
|
+
}
|
|
371
|
+
MapsIndoors.removeVenuesToSync(venueList);
|
|
372
|
+
promise.resolve(null);
|
|
373
|
+
} catch (Exception e) {
|
|
374
|
+
promise.reject(e);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
@ReactMethod
|
|
379
|
+
public void getSyncedVenues(final Promise promise) {
|
|
380
|
+
List<String> venues = MapsIndoors.getSyncedVenues();
|
|
381
|
+
if (venues != null) {
|
|
382
|
+
ReadableArray array = Arguments.fromList(venues);
|
|
383
|
+
promise.resolve(array);
|
|
384
|
+
} else {
|
|
385
|
+
promise.resolve(null);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
@ReactMethod
|
|
390
|
+
public void cacheData(String apiKey, Promise promise) {
|
|
391
|
+
if (!MPDataSetCacheManager.isInitialized()) {
|
|
392
|
+
MPDataSetCacheManager.initialize(reactContext);
|
|
393
|
+
}
|
|
394
|
+
MPDataSetCache cache = MPDataSetCacheManager.getInstance().getDataSetByID(apiKey);
|
|
395
|
+
if (cache == null) {
|
|
396
|
+
cache = MPDataSetCacheManager.getInstance().addDataSetWithCachingScope(apiKey, MPDataSetCacheScope.FULL);
|
|
397
|
+
}else {
|
|
398
|
+
cache.setScope(MPDataSetCacheScope.FULL);
|
|
399
|
+
}
|
|
400
|
+
MPDataSetCache finalCache = cache;
|
|
401
|
+
MPDataSetCacheManager.getInstance().addMPDataSetCacheSyncListener(((mpDataSetCache, i) -> {
|
|
402
|
+
if (i == MPDataSetManagerStatus.SYNC_FINISHED && finalCache.getSolutionId().equals(mpDataSetCache.getSolutionId())) {
|
|
403
|
+
promise.resolve(true);
|
|
404
|
+
} else if (i == MPDataSetManagerStatus.SYNC_FAILED && finalCache.getSolutionId().equals(mpDataSetCache.getSolutionId())) {
|
|
405
|
+
promise.resolve(false);
|
|
406
|
+
}
|
|
407
|
+
}));
|
|
408
|
+
MPDataSetCacheManager.getInstance().synchronizeDataSets(Collections.singletonList(cache));
|
|
409
|
+
}
|
|
410
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package com.mapsindoorsrn.core;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
6
|
+
import com.mapsindoors.core.MPIMapConfig;
|
|
7
|
+
import com.mapsindoors.core.OnResultReadyListener;
|
|
8
|
+
import com.mapsindoorsrn.core.models.MPCameraPosition;
|
|
9
|
+
import com.mapsindoorsrn.core.models.MPCameraUpdate;
|
|
10
|
+
|
|
11
|
+
public interface RCMapView {
|
|
12
|
+
void animateCamera(MPCameraUpdate cameraUpdate, Integer duration, OnResultReadyListener onFinished);
|
|
13
|
+
void moveCamera(MPCameraUpdate cameraUpdate);
|
|
14
|
+
MPCameraPosition getCurrentCameraPosition();
|
|
15
|
+
MPIMapConfig parseConfig(ReadableMap configMap, Activity activity);
|
|
16
|
+
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
package com.mapsindoorsrn.core;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.bridge.Promise;
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
8
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
9
|
+
import com.google.gson.Gson;
|
|
10
|
+
import com.mapsindoors.core.MPCollisionHandling;
|
|
11
|
+
import com.mapsindoors.core.MPGeometry;
|
|
12
|
+
import com.mapsindoors.core.MPLocation;
|
|
13
|
+
import com.mapsindoors.core.MPLocationSettings;
|
|
14
|
+
import com.mapsindoors.core.MPMultiPolygonGeometry;
|
|
15
|
+
import com.mapsindoors.core.MPPOIType;
|
|
16
|
+
import com.mapsindoors.core.MPPoint;
|
|
17
|
+
import com.mapsindoors.core.MPPolygonGeometry;
|
|
18
|
+
import com.mapsindoors.core.MPSolution;
|
|
19
|
+
import com.mapsindoors.core.MPVenue;
|
|
20
|
+
import com.mapsindoors.core.MapsIndoors;
|
|
21
|
+
import com.mapsindoors.core.MPJsonParser;
|
|
22
|
+
import com.mapsindoors.core.errors.MIError;
|
|
23
|
+
import com.mapsindoors.core.errors.MIErrorEnum;
|
|
24
|
+
import com.mapsindoorsrn.core.models.MPError;
|
|
25
|
+
|
|
26
|
+
import java.util.Locale;
|
|
27
|
+
|
|
28
|
+
public class UtilsModule extends ReactContextBaseJavaModule {
|
|
29
|
+
|
|
30
|
+
private final Gson gson = new Gson();
|
|
31
|
+
|
|
32
|
+
public UtilsModule(ReactApplicationContext reactApplicationContext) {
|
|
33
|
+
super(reactApplicationContext);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@NonNull
|
|
37
|
+
@Override
|
|
38
|
+
public String getName() {
|
|
39
|
+
return "UtilsModule";
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private void reject(Promise promise, MIError error) {
|
|
43
|
+
promise.reject("UtilError", gson.toJson(MPError.fromMIError(error)));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@ReactMethod
|
|
47
|
+
public void venueHasGraph(String venueId, final Promise promise) {
|
|
48
|
+
if (MapsIndoors.getVenues() != null) {
|
|
49
|
+
MPVenue venue = MapsIndoors.getVenues().getVenueById(venueId);
|
|
50
|
+
if (venue != null) {
|
|
51
|
+
promise.resolve(venue.hasGraph());
|
|
52
|
+
} else {
|
|
53
|
+
reject(promise, new MIError(MIErrorEnum.UNKNOWN_ERROR, "Cannot find venue with ID: " + venueId));
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
reject(promise, new MIError(MIErrorEnum.UNKNOWN_ERROR, "Venues are not available"));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@ReactMethod
|
|
62
|
+
public void pointAngleBetween(String point1, String point2, final Promise promise) {
|
|
63
|
+
MPPoint it = MPJsonParser.parse(point1, MPPoint.class);
|
|
64
|
+
MPPoint other = MPJsonParser.parse(point2, MPPoint.class);
|
|
65
|
+
|
|
66
|
+
if (it != null && other != null) {
|
|
67
|
+
promise.resolve(it.angleBetween(other));
|
|
68
|
+
} else {
|
|
69
|
+
reject(promise, new MIError(MIErrorEnum.UNKNOWN_ERROR, "One or more points are null: " + point1 + ", " + point2));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@ReactMethod
|
|
74
|
+
public void pointDistanceTo(String point1, String point2, final Promise promise) {
|
|
75
|
+
MPPoint it = MPJsonParser.parse(point1, MPPoint.class);
|
|
76
|
+
MPPoint other = MPJsonParser.parse(point2, MPPoint.class);
|
|
77
|
+
|
|
78
|
+
if (it != null && other != null) {
|
|
79
|
+
promise.resolve(it.distanceTo(other));
|
|
80
|
+
} else {
|
|
81
|
+
reject(promise, new MIError(MIErrorEnum.UNKNOWN_ERROR, "One or more points are null: " + point1 + ", " + point2));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@ReactMethod
|
|
86
|
+
public void geometryIsInside(String pointString, String geometryString, final Promise promise) {
|
|
87
|
+
MPPoint point = MPJsonParser.parse(pointString, MPPoint.class);
|
|
88
|
+
MPGeometry geometry = MPJsonParser.parse(geometryString, MPGeometry.class);
|
|
89
|
+
if (point != null && geometry != null) {
|
|
90
|
+
promise.resolve(geometry.isInside(point.getLatLng()));
|
|
91
|
+
} else {
|
|
92
|
+
reject(promise, new MIError(MIErrorEnum.UNKNOWN_ERROR, "Point (" + point + ") and/or Geometry (" + geometry + ") is null"));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@ReactMethod
|
|
97
|
+
public void geometryArea(String geometryString, final Promise promise) {
|
|
98
|
+
MPGeometry geometry = MPJsonParser.parse(geometryString, MPGeometry.class);
|
|
99
|
+
if (geometry != null) {
|
|
100
|
+
promise.resolve(geometry.getArea());
|
|
101
|
+
} else {
|
|
102
|
+
reject(promise, new MIError(MIErrorEnum.UNKNOWN_ERROR, "Geometry is null"));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
@ReactMethod
|
|
107
|
+
public void polygonDistanceToClosestEdge(String pointString, String geometryString, final Promise promise) {
|
|
108
|
+
MPPoint point = MPJsonParser.parse(pointString, MPPoint.class);
|
|
109
|
+
MPGeometry geometry = MPJsonParser.parse(geometryString, MPGeometry.class);
|
|
110
|
+
if (geometry != null && point != null) {
|
|
111
|
+
if (MPGeometry.POLYGON.equals(geometry.getType()) ) {
|
|
112
|
+
MPPolygonGeometry polygonGeometry = (MPPolygonGeometry) geometry;
|
|
113
|
+
promise.resolve(polygonGeometry.getSquaredDistanceToClosestEdge(point));
|
|
114
|
+
} else if (MPGeometry.MULTIPOLYGON.equals(geometry.getType())) {
|
|
115
|
+
MPMultiPolygonGeometry multiPolygonGeometry = (MPMultiPolygonGeometry) geometry;
|
|
116
|
+
promise.resolve(multiPolygonGeometry.getSquaredDistanceToClosestEdge(point));
|
|
117
|
+
} else {
|
|
118
|
+
reject(promise, new MIError(MIErrorEnum.UNKNOWN_ERROR, "Geometry of incompatible type: " + geometry.getType() +
|
|
119
|
+
" (should be " + MPGeometry.POLYGON + " or "+ MPGeometry.MULTIPOLYGON + ")"));
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
reject(promise, new MIError(MIErrorEnum.UNKNOWN_ERROR, "Point (" + point + ") or Geometry (" + geometry + ") is null"));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@ReactMethod
|
|
127
|
+
public void parseMapClientUrl(String venueId, String locationId, final Promise promise) {
|
|
128
|
+
MPSolution solution = MapsIndoors.getSolution();
|
|
129
|
+
if (solution != null) {
|
|
130
|
+
promise.resolve(solution.parseMapClientUrl(venueId, locationId));
|
|
131
|
+
} else {
|
|
132
|
+
reject(promise, new MIError(MIErrorEnum.UNKNOWN_ERROR, "Solution is null, MapsIndoors is probably not ready yet"));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@ReactMethod
|
|
137
|
+
public void setCollisionHandling(Double collisionHandling, final Promise promise) {
|
|
138
|
+
MPSolution solution = MapsIndoors.getSolution();
|
|
139
|
+
if (solution != null) {
|
|
140
|
+
solution.getConfig().setCollisionHandling(MPCollisionHandling.fromValue(collisionHandling.intValue()));
|
|
141
|
+
}
|
|
142
|
+
promise.resolve(null);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@ReactMethod
|
|
146
|
+
public void enableClustering(boolean enable, final Promise promise) {
|
|
147
|
+
MPSolution solution = MapsIndoors.getSolution();
|
|
148
|
+
if (solution != null) {
|
|
149
|
+
solution.getConfig().setEnableClustering(enable);
|
|
150
|
+
}
|
|
151
|
+
promise.resolve(null);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@ReactMethod
|
|
155
|
+
public void setNewSelection(boolean enable, final Promise promise) {
|
|
156
|
+
MPSolution solution = MapsIndoors.getSolution();
|
|
157
|
+
if (solution != null) {
|
|
158
|
+
solution.getConfig().setNewSelection(enable);
|
|
159
|
+
}
|
|
160
|
+
promise.resolve(null);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@ReactMethod
|
|
164
|
+
public void setExtrusionOpacity(Double extrusionOpacity, final Promise promise) {
|
|
165
|
+
MPSolution solution = MapsIndoors.getSolution();
|
|
166
|
+
if (solution != null) {
|
|
167
|
+
solution.getConfig().getSettings3D().setExtrusionOpacity(extrusionOpacity.floatValue());
|
|
168
|
+
}
|
|
169
|
+
promise.resolve(null);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
@ReactMethod
|
|
173
|
+
public void setWallOpacity(Double wallOpacity, final Promise promise) {
|
|
174
|
+
MPSolution solution = MapsIndoors.getSolution();
|
|
175
|
+
if (solution != null) {
|
|
176
|
+
solution.getConfig().getSettings3D().setWallOpacity(wallOpacity.floatValue());
|
|
177
|
+
}
|
|
178
|
+
promise.resolve(null);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
@ReactMethod
|
|
182
|
+
public void setSelectable(String id, boolean selectable, final Promise promise) {
|
|
183
|
+
MPSolution solution = MapsIndoors.getSolution();
|
|
184
|
+
if (solution != null) {
|
|
185
|
+
if (id.equals("solution")) {
|
|
186
|
+
solution.getConfig().getLocationSettings().setSelectable(selectable);
|
|
187
|
+
} else {
|
|
188
|
+
MPLocation location = MapsIndoors.getLocationById(id);
|
|
189
|
+
if (location != null) {
|
|
190
|
+
if (location.getLocationSettings() == null) {
|
|
191
|
+
location.setLocationSettings(new MPLocationSettings(selectable));
|
|
192
|
+
}else {
|
|
193
|
+
location.getLocationSettings().setSelectable(selectable);
|
|
194
|
+
}
|
|
195
|
+
}else {
|
|
196
|
+
for (MPPOIType type : solution.getTypes()) {
|
|
197
|
+
if (type.getName().equals(id.toLowerCase(Locale.ROOT))) {
|
|
198
|
+
if (type.getLocationSettings() == null) {
|
|
199
|
+
type.setLocationSettings(new MPLocationSettings(selectable));
|
|
200
|
+
}else {
|
|
201
|
+
type.getLocationSettings().setSelectable(selectable);
|
|
202
|
+
}
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
} else {
|
|
209
|
+
reject(promise, new MIError(MIErrorEnum.UNKNOWN_ERROR, "Solution is null, MapsIndoors needs to be loaded before setting selectable"));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
promise.resolve(null);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
@ReactMethod
|
|
216
|
+
public void setAutomatedZoomLimit(Double zoomLimit, final Promise promise) {
|
|
217
|
+
MPSolution solution = MapsIndoors.getSolution();
|
|
218
|
+
if (solution != null) {
|
|
219
|
+
if (zoomLimit == -1) {
|
|
220
|
+
solution.getConfig().setAutomatedZoomLimit(null);
|
|
221
|
+
}else {
|
|
222
|
+
solution.getConfig().setAutomatedZoomLimit(zoomLimit);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
promise.resolve(null);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package com.mapsindoorsrn.core.models;
|
|
2
|
+
|
|
3
|
+
import android.graphics.Bitmap;
|
|
4
|
+
|
|
5
|
+
import androidx.annotation.Nullable;
|
|
6
|
+
|
|
7
|
+
import com.mapsindoors.core.MPRouteStopIconProvider;
|
|
8
|
+
|
|
9
|
+
public class BitmapStopIconConfig extends MPRouteStopIconProvider {
|
|
10
|
+
|
|
11
|
+
private final Bitmap bitmap;
|
|
12
|
+
|
|
13
|
+
public BitmapStopIconConfig(Bitmap bitmap) {
|
|
14
|
+
this.bitmap = bitmap;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@Nullable
|
|
18
|
+
@Override
|
|
19
|
+
public Bitmap getImage() {
|
|
20
|
+
return bitmap;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package com.mapsindoorsrn.core.models;
|
|
2
|
+
|
|
3
|
+
import com.google.gson.annotations.SerializedName;
|
|
4
|
+
import com.mapsindoors.core.MPPoint;
|
|
5
|
+
|
|
6
|
+
public class Bounds {
|
|
7
|
+
@SerializedName("northeast")
|
|
8
|
+
private MPPoint northEast;
|
|
9
|
+
@SerializedName("southwest")
|
|
10
|
+
private MPPoint southWest;
|
|
11
|
+
|
|
12
|
+
public MPPoint getNorthEast() {
|
|
13
|
+
return northEast;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public MPPoint getSouthWest() {
|
|
17
|
+
return southWest;
|
|
18
|
+
}
|
|
19
|
+
}
|