@mapsindoors/react-native-maps-indoors-mapbox 0.0.5-beta → 1.0.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 (127) hide show
  1. package/README.md +7 -2
  2. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  3. package/android/.gradle/7.4/checksums/md5-checksums.bin +0 -0
  4. package/android/.gradle/7.4/checksums/sha1-checksums.bin +0 -0
  5. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  6. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  7. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  8. package/android/.idea/jarRepositories.xml +15 -0
  9. package/android/.idea/misc.xml +1 -1
  10. package/android/.idea/vcs.xml +2 -1
  11. package/android/build.gradle +2 -5
  12. package/android/src/main/java/com/reactlibrary/MapboxMapView.java +116 -0
  13. package/android/src/main/java/com/reactlibrary/MapsIndoorsPackage.java +9 -2
  14. package/android/src/main/java/com/reactlibrary/{DirectionsRendererModule.java → core/DirectionsRendererModule.java} +3 -2
  15. package/android/src/main/java/com/reactlibrary/{DirectionsServiceModule.java → core/DirectionsServiceModule.java} +1 -1
  16. package/android/src/main/java/com/reactlibrary/{MPDisplayRuleModule.java → core/MPDisplayRuleModule.java} +3 -3
  17. package/android/src/main/java/com/reactlibrary/{MapControlModule.java → core/MapControlModule.java} +31 -64
  18. package/android/src/main/java/com/reactlibrary/{MapsIndoorsModule.java → core/MapsIndoorsModule.java} +6 -6
  19. package/android/src/main/java/com/reactlibrary/core/RCMapView.java +16 -0
  20. package/android/src/main/java/com/reactlibrary/core/README.md +92 -0
  21. package/android/src/main/java/com/reactlibrary/{UtilsModule.java → core/UtilsModule.java} +13 -12
  22. package/android/src/main/java/com/reactlibrary/{models → core/models}/Bounds.java +1 -1
  23. package/android/src/main/java/com/reactlibrary/{models → core/models}/Filter.java +1 -1
  24. package/android/src/main/java/com/reactlibrary/{models → core/models}/Location.java +1 -1
  25. package/android/src/main/java/com/reactlibrary/{models → core/models}/MPCameraPosition.java +12 -7
  26. package/android/src/main/java/com/reactlibrary/core/models/MPCameraUpdate.java +68 -0
  27. package/android/src/main/java/com/reactlibrary/{models → core/models}/MPError.java +1 -1
  28. package/android/src/main/java/com/reactlibrary/{models → core/models}/PositionProvider.java +1 -1
  29. package/android/src/main/java/com/reactlibrary/{models → core/models}/PositionResult.java +1 -1
  30. package/android/src/main/java/com/reactlibrary/{models → core/models}/Query.java +1 -1
  31. package/index.ts +88 -89
  32. package/ios/MapsIndoorsViewManager.swift +90 -9
  33. package/ios/core/CameraPosition.swift +15 -0
  34. package/ios/core/CameraUpdate.swift +19 -0
  35. package/ios/core/CameraUpdateError.swift +11 -0
  36. package/ios/{DirectionsRendererBridge.m → core/DirectionsRendererBridge.m} +9 -5
  37. package/ios/{DirectionsRendererModule.swift → core/DirectionsRendererModule.swift} +89 -39
  38. package/ios/{MapControlModule.swift → core/MapControlModule.swift} +21 -108
  39. package/ios/{MapsIndoorsBridge.m → core/MapsIndoorsBridge.m} +18 -0
  40. package/ios/{MapsIndoorsData.swift → core/MapsIndoorsData.swift} +19 -4
  41. package/ios/{MapsIndoorsModule.swift → core/MapsIndoorsModule.swift} +50 -1
  42. package/ios/core/RCMapView.swift +14 -0
  43. package/ios/core/README.md +92 -0
  44. package/ios/{UtilsModule.swift → core/UtilsModule.swift} +4 -4
  45. package/package.json +6 -5
  46. package/react-native-maps-indoors-mapbox.podspec +2 -2
  47. package/src/{MPBounds.ts → core/MPBounds.ts} +25 -7
  48. package/src/{MPBuilding.ts → core/MPBuilding.ts} +4 -4
  49. package/src/{MPCameraEvent.ts → core/MPCameraEvent.ts} +1 -1
  50. package/src/{MPCameraEventListener.ts → core/MPCameraEventListener.ts} +1 -1
  51. package/src/{MPCameraPosition.ts → core/MPCameraPosition.ts} +2 -3
  52. package/src/{MPCategory.ts → core/MPCategory.ts} +1 -1
  53. package/src/{MPDirectionsRenderer.ts → core/MPDirectionsRenderer.ts} +4 -4
  54. package/src/{MPDirectionsService.ts → core/MPDirectionsService.ts} +1 -1
  55. package/src/{MPDisplayRule.ts → core/MPDisplayRule.ts} +1 -1
  56. package/src/{MPEntity.ts → core/MPEntity.ts} +1 -1
  57. package/src/{MPEntityInfo.ts → core/MPEntityInfo.ts} +1 -1
  58. package/src/{MPFilter.ts → core/MPFilter.ts} +1 -1
  59. package/src/{MPFilterBehavior.ts → core/MPFilterBehavior.ts} +6 -6
  60. package/src/{MPFloor.ts → core/MPFloor.ts} +1 -1
  61. package/src/{MPFloorSelectorInterface.ts → core/MPFloorSelectorInterface.ts} +1 -1
  62. package/src/{MPLocation.ts → core/MPLocation.ts} +3 -3
  63. package/src/{MPMapConfig.ts → core/MPMapConfig.ts} +1 -1
  64. package/src/{MPMultiPolygon.ts → core/MPMultiPolygon.ts} +18 -5
  65. package/src/{MPPoint.ts → core/MPPoint.ts} +14 -10
  66. package/src/{MPPolygon.ts → core/MPPolygon.ts} +18 -5
  67. package/src/{MPPositionProviderInterface.ts → core/MPPositionProviderInterface.ts} +1 -1
  68. package/src/{MPPositionResultInterface.ts → core/MPPositionResultInterface.ts} +1 -1
  69. package/src/{MPPropertyData.ts → core/MPPropertyData.ts} +2 -2
  70. package/src/{MPQuery.ts → core/MPQuery.ts} +1 -1
  71. package/src/{MPRoute.ts → core/MPRoute.ts} +1 -1
  72. package/src/{MPRouteCoordinate.ts → core/MPRouteCoordinate.ts} +1 -1
  73. package/src/{MPRouteLeg.ts → core/MPRouteLeg.ts} +1 -1
  74. package/src/{MPRouteStep.ts → core/MPRouteStep.ts} +1 -1
  75. package/src/{MPSelectionBehavior.ts → core/MPSelectionBehavior.ts} +6 -6
  76. package/src/{MPSettings3D.ts → core/MPSettings3D.ts} +1 -1
  77. package/src/{MPSolution.ts → core/MPSolution.ts} +1 -1
  78. package/src/{MPSolutionConfig.ts → core/MPSolutionConfig.ts} +3 -3
  79. package/src/{MPSolutionDisplayRule.ts → core/MPSolutionDisplayRule.ts} +1 -1
  80. package/src/{MPUserRoleCollection.ts → core/MPUserRoleCollection.ts} +1 -1
  81. package/src/{MPUtils.ts → core/MPUtils.ts} +1 -1
  82. package/src/{MPVenue.ts → core/MPVenue.ts} +1 -1
  83. package/src/{MapControl.ts → core/MapControl.ts} +5 -2
  84. package/src/{MapsIndoors.ts → core/MapsIndoors.ts} +1 -1
  85. package/src/{OnBuildingFoundAtCameraTargetListener.ts → core/OnBuildingFoundAtCameraTargetListener.ts} +1 -1
  86. package/src/{OnFloorSelectionChangedListener.ts → core/OnFloorSelectionChangedListener.ts} +1 -1
  87. package/src/{OnLegSelectedListener.ts → core/OnLegSelectedListener.ts} +1 -1
  88. package/src/{OnLocationSelectedListener.ts → core/OnLocationSelectedListener.ts} +1 -1
  89. package/src/{OnMapClickListener.ts → core/OnMapClickListener.ts} +1 -1
  90. package/src/{OnMarkerClickListener.ts → core/OnMarkerClickListener.ts} +1 -1
  91. package/src/{OnMarkerInfoWindowClickListener.ts → core/OnMarkerInfoWindowClickListener.ts} +1 -1
  92. package/src/{OnPositionUpdateListener.ts → core/OnPositionUpdateListener.ts} +1 -1
  93. package/src/{OnVenueFoundAtCameraTargetListener.ts → core/OnVenueFoundAtCameraTargetListener.ts} +1 -1
  94. package/src/core/README.md +92 -0
  95. package/android/src/main/java/com/reactlibrary/models/MPCameraUpdate.java +0 -92
  96. /package/ios/{DirectionsServiceBridge.m → core/DirectionsServiceBridge.m} +0 -0
  97. /package/ios/{DirectionsServiceModule.swift → core/DirectionsServiceModule.swift} +0 -0
  98. /package/ios/{MPDisplayRuleBridge.m → core/MPDisplayRuleBridge.m} +0 -0
  99. /package/ios/{MPDisplayRuleModule.swift → core/MPDisplayRuleModule.swift} +0 -0
  100. /package/ios/{MapControlBridge.m → core/MapControlBridge.m} +0 -0
  101. /package/ios/{ReactPositionProvider.swift → core/ReactPositionProvider.swift} +0 -0
  102. /package/ios/{UtilsBridge.m → core/UtilsBridge.m} +0 -0
  103. /package/ios/{helpers.swift → core/helpers.swift} +0 -0
  104. /package/src/{EventNames.ts → core/EventNames.ts} +0 -0
  105. /package/src/{MPBuildingCollection.ts → core/MPBuildingCollection.ts} +0 -0
  106. /package/src/{MPBuildingInfo.ts → core/MPBuildingInfo.ts} +0 -0
  107. /package/src/{MPCameraUpdate.ts → core/MPCameraUpdate.ts} +0 -0
  108. /package/src/{MPCameraViewFitMode.ts → core/MPCameraViewFitMode.ts} +0 -0
  109. /package/src/{MPCategoryCollection.ts → core/MPCategoryCollection.ts} +0 -0
  110. /package/src/{MPCollection.ts → core/MPCollection.ts} +0 -0
  111. /package/src/{MPCollisionHandling.ts → core/MPCollisionHandling.ts} +0 -0
  112. /package/src/{MPDataField.ts → core/MPDataField.ts} +0 -0
  113. /package/src/{MPError.ts → core/MPError.ts} +0 -0
  114. /package/src/{MPGeometry.ts → core/MPGeometry.ts} +0 -0
  115. /package/src/{MPHighway.ts → core/MPHighway.ts} +0 -0
  116. /package/src/{MPIconSize.ts → core/MPIconSize.ts} +0 -0
  117. /package/src/{MPLocationPropertyNames.ts → core/MPLocationPropertyNames.ts} +0 -0
  118. /package/src/{MPLocationType.ts → core/MPLocationType.ts} +0 -0
  119. /package/src/{MPMapStyle.ts → core/MPMapStyle.ts} +0 -0
  120. /package/src/{MPRouteProperty.ts → core/MPRouteProperty.ts} +0 -0
  121. /package/src/{MPSize.ts → core/MPSize.ts} +0 -0
  122. /package/src/{MPUserRole.ts → core/MPUserRole.ts} +0 -0
  123. /package/src/{MPVenueCollection.ts → core/MPVenueCollection.ts} +0 -0
  124. /package/src/{MPVenueInfo.ts → core/MPVenueInfo.ts} +0 -0
  125. /package/src/{MapView.tsx → core/MapView.tsx} +0 -0
  126. /package/src/{OnFloorUpdateListener.ts → core/OnFloorUpdateListener.ts} +0 -0
  127. /package/src/{OnLiveLocationUpdateListener.ts → core/OnLiveLocationUpdateListener.ts} +0 -0
package/README.md CHANGED
@@ -2,14 +2,19 @@
2
2
 
3
3
  ## Getting started
4
4
 
5
- `$ npm install react-native-maps-indoors-mapbox`
5
+ `$ npm install @mapsindoors/react-native-maps-indoors-mapbox`
6
6
 
7
7
  ### iOS
8
8
 
9
- The MapsIndoors SDK requires iOS 13, so make sure that your podfile is configured for iOS 13
9
+ The MapsIndoors SDK requires iOS 13, so make sure that your podfile is configured for iOS 13.
10
+ Add !use_frameworks inside your app target as well.
10
11
 
11
12
  ```pod
12
13
  platform :ios, '13.0
14
+
15
+ target 'MyApp' do
16
+ use_frameworks!
17
+ ...
13
18
  ```
14
19
 
15
20
  #### Providing API key
@@ -41,5 +41,20 @@
41
41
  <option name="name" value="maven" />
42
42
  <option name="url" value="https://maven.mapsindoors.com/" />
43
43
  </remote-repository>
44
+ <remote-repository>
45
+ <option name="id" value="maven3" />
46
+ <option name="name" value="maven3" />
47
+ <option name="url" value="file:$USER_HOME$/React%20Native%20with%20submodules/react-native-mapsindoors-mapbox/node_modules/jsc-android/dist/" />
48
+ </remote-repository>
49
+ <remote-repository>
50
+ <option name="id" value="maven4" />
51
+ <option name="name" value="maven4" />
52
+ <option name="url" value="https://api.mapbox.com/downloads/v2/releases/maven" />
53
+ </remote-repository>
54
+ <remote-repository>
55
+ <option name="id" value="maven2" />
56
+ <option name="name" value="maven2" />
57
+ <option name="url" value="file:$USER_HOME$/React%20Native%20with%20submodules/react-native-mapsindoors-mapbox/node_modules/react-native/android/" />
58
+ </remote-repository>
44
59
  </component>
45
60
  </project>
@@ -1,7 +1,7 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <project version="4">
3
3
  <component name="ExternalStorageConfigurationManager" enabled="true" />
4
- <component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="1.8" project-jdk-type="JavaSDK">
4
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
5
5
  <output url="file://$PROJECT_DIR$/build/classes" />
6
6
  </component>
7
7
  <component name="ProjectType">
@@ -1,6 +1,7 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <project version="4">
3
3
  <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$/../../.." vcs="Git" />
4
+ <mapping directory="$USER_HOME$" vcs="Git" />
5
+ <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
5
6
  </component>
6
7
  </project>
@@ -92,11 +92,8 @@ dependencies {
92
92
  }
93
93
  }
94
94
 
95
- implementation 'com.mapbox.maps:android:10.13.0'
96
-
97
-
98
-
99
- implementation 'com.mapspeople.mapsindoors:mapbox:4.1.6'
95
+ implementation 'com.mapbox.maps:android:10.14.1'
96
+ implementation 'com.mapspeople.mapsindoors:mapbox:4.1.10'
100
97
  implementation 'com.facebook.react:react-native:+' // From node_modules
101
98
  implementation 'androidx.core:core-ktx:1.3.2'
102
99
  }
@@ -0,0 +1,116 @@
1
+ package com.reactlibrary;
2
+
3
+ import android.app.Activity;
4
+ import android.graphics.Typeface;
5
+ import android.content.Context;
6
+
7
+ import com.facebook.react.bridge.ReadableMap;
8
+ import com.mapbox.geojson.Point;
9
+ import com.mapbox.maps.CameraOptions;
10
+ import com.mapbox.maps.CameraState;
11
+ import com.mapbox.maps.CoordinateBounds;
12
+ import com.mapbox.maps.EdgeInsets;
13
+ import com.mapbox.maps.MapView;
14
+ import com.mapsindoors.core.MPIMapConfig;
15
+ import com.mapsindoors.core.MPPoint;
16
+ import com.mapsindoors.core.OnResultReadyListener;
17
+ import com.mapsindoors.mapbox.MPMapConfig;
18
+ import com.reactlibrary.core.RCMapView;
19
+ import com.reactlibrary.core.models.MPCameraPosition;
20
+ import com.reactlibrary.core.models.MPCameraUpdate;
21
+
22
+ public class MapboxMapView implements RCMapView {
23
+ private MapView mMapView;
24
+ private Context mContext;
25
+
26
+ public MapboxMapView(MapView mapView, Context context) {
27
+ mMapView = mapView;
28
+ mContext = context;
29
+ }
30
+
31
+ @Override
32
+ public void animateCamera(MPCameraUpdate cameraUpdate, Integer duration, OnResultReadyListener onFinished) {
33
+ CameraOptions cameraOptions = toCameraOptions(cameraUpdate);
34
+ mMapView.getMapboxMap().setCamera(cameraOptions);
35
+ onFinished.onResultReady(null);
36
+ }
37
+
38
+ @Override
39
+ public void moveCamera(MPCameraUpdate cameraUpdate) {
40
+ CameraOptions cameraOptions = toCameraOptions(cameraUpdate);
41
+ mMapView.getMapboxMap().setCamera(cameraOptions);
42
+ }
43
+
44
+ @Override
45
+ public MPCameraPosition getCurrentCameraPosition() {
46
+ CameraState cameraState = mMapView.getMapboxMap().getCameraState();
47
+ return new MPCameraPosition(Double.valueOf(cameraState.getZoom()).floatValue(),
48
+ Double.valueOf(cameraState.getPitch()).floatValue(),
49
+ Double.valueOf(cameraState.getBearing()).floatValue(),
50
+ new MPPoint(cameraState.getCenter().latitude(), cameraState.getCenter().longitude()));
51
+ }
52
+
53
+ @Override
54
+ public MPIMapConfig parseConfig(ReadableMap configMap, Activity activity) {
55
+ String apiKey = activity.getString(R.string.mapbox_api_key);
56
+ boolean useDefaultStyle = !configMap.hasKey("useDefaultMapsIndoorsStyle") || configMap.getBoolean("useDefaultMapsIndoorsStyle");
57
+ MPMapConfig.Builder config = new MPMapConfig.Builder(activity, mMapView.getMapboxMap(), mMapView, apiKey, useDefaultStyle);
58
+
59
+ if (configMap.hasKey("typeface")) {
60
+ config.setMapLabelFont(Typeface.create("typeface", Typeface.NORMAL), configMap.getString("color"), configMap.getBoolean("showHalo"));
61
+ }
62
+
63
+ if (configMap.hasKey("textSize")) {
64
+ config.setMapLabelTextSize(configMap.getInt("textSize"));
65
+ }
66
+
67
+ if (configMap.hasKey("showFloorSelector")) {
68
+ config.setShowFloorSelector(configMap.getBoolean("showFloorSelector"));
69
+ }
70
+
71
+ if (configMap.hasKey("showInfoWindowOnClick")) {
72
+ config.setShowInfoWindowOnLocationClicked(configMap.getBoolean("showInfoWindowOnClick"));
73
+ }
74
+
75
+ if (configMap.hasKey("showUserPosition")) {
76
+ config.setShowUserPosition(configMap.getBoolean("showUserPosition"));
77
+ }
78
+
79
+ if (configMap.hasKey("enableTileFadeIn")) {
80
+ config.setTileFadeInEnabled(configMap.getBoolean("enableTileFadeIn"));
81
+ }
82
+
83
+ return config.build();
84
+ }
85
+
86
+ public CameraOptions toCameraOptions(MPCameraUpdate cameraUpdate) {
87
+ MPCameraUpdate.CameraUpdateMode mode = cameraUpdate.getMode();
88
+ if (mode == null) {
89
+ return null;
90
+ }
91
+
92
+ switch (mode) {
93
+ case FROM_POINT:
94
+ return new CameraOptions.Builder().center(Point.fromLngLat(cameraUpdate.point.getLng(), cameraUpdate.point.getLat())).build();
95
+ case FROM_BOUNDS:
96
+ Point southWest = Point.fromLngLat(cameraUpdate.bounds.getSouthWest().getLng(), cameraUpdate.bounds.getSouthWest().getLat());
97
+ Point northEast = Point.fromLngLat(cameraUpdate.bounds.getNorthEast().getLng(), cameraUpdate.bounds.getNorthEast().getLat());
98
+ CoordinateBounds coordinateBounds = new CoordinateBounds(southWest, northEast);
99
+ Double padding = (double) (mContext.getResources().getDisplayMetrics().density * cameraUpdate.padding);
100
+ return mMapView.getMapboxMap().cameraForCoordinateBounds(coordinateBounds, new EdgeInsets(padding, padding, padding, padding), null, null);
101
+ case ZOOM_BY:
102
+ return new CameraOptions.Builder().zoom(mMapView.getMapboxMap().getCameraState().getZoom() + cameraUpdate.zoom).build();
103
+ case ZOOM_TO:
104
+ return new CameraOptions.Builder().zoom(Double.valueOf(cameraUpdate.zoom)).build();
105
+ case FROM_CAMERA_POSITION:
106
+ return new CameraOptions.Builder()
107
+ .center(Point.fromLngLat(cameraUpdate.position.target.getLng(), cameraUpdate.position.target.getLat()))
108
+ .zoom(Double.valueOf(cameraUpdate.position.zoom))
109
+ .bearing(Double.valueOf(cameraUpdate.position.bearing))
110
+ .pitch(Double.valueOf(cameraUpdate.position.tilt))
111
+ .build();
112
+ }
113
+ return null;
114
+ }
115
+
116
+ }
@@ -13,14 +13,22 @@ import com.facebook.react.bridge.ReactApplicationContext;
13
13
  import com.facebook.react.uimanager.ViewManager;
14
14
  import com.mapsindoors.core.OnResultReadyListener;
15
15
  import com.mapsindoors.core.errors.MIError;
16
+ import com.reactlibrary.core.DirectionsRendererModule;
17
+ import com.reactlibrary.core.DirectionsServiceModule;
18
+ import com.reactlibrary.core.MPDisplayRuleModule;
19
+ import com.reactlibrary.core.MapControlModule;
20
+ import com.reactlibrary.core.MapsIndoorsModule;
21
+ import com.reactlibrary.core.UtilsModule;
16
22
 
17
23
  public class MapsIndoorsPackage implements ReactPackage, OnResultReadyListener {
18
24
  private MapControlModule mapControlModule;
19
25
  private MapsIndoorsViewManager viewManager;
26
+ private ReactApplicationContext mContext;
20
27
 
21
28
  @NonNull
22
29
  @Override
23
30
  public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
31
+ mContext = reactContext;
24
32
  mapControlModule = new MapControlModule(reactContext);
25
33
  return Arrays.asList(
26
34
  new MapsIndoorsModule(reactContext),
@@ -40,7 +48,6 @@ public class MapsIndoorsPackage implements ReactPackage, OnResultReadyListener {
40
48
 
41
49
  @Override
42
50
  public void onResultReady(@Nullable MIError miError) {
43
- mapControlModule.setMap(viewManager.getView().getMapboxMap());
44
- mapControlModule.setView(viewManager.getView());
51
+ mapControlModule.setView(new MapboxMapView(viewManager.getView(), mContext));
45
52
  }
46
53
  }
@@ -1,4 +1,4 @@
1
- package com.reactlibrary;
1
+ package com.reactlibrary.core;
2
2
 
3
3
  import android.graphics.Color;
4
4
 
@@ -21,7 +21,8 @@ import com.mapsindoors.core.OnMapControlReadyListener;
21
21
  import com.mapsindoors.core.errors.MIError;
22
22
  import com.mapsindoors.core.errors.MIErrorEnum;
23
23
  import com.mapsindoors.core.errors.MapsIndoorsException;
24
- import com.reactlibrary.models.MPError;
24
+ import com.reactlibrary.core.models.MPError;
25
+
25
26
 
26
27
  public class DirectionsRendererModule extends ReactContextBaseJavaModule implements OnMapControlReadyListener {
27
28
  private MapControl mMapControl;
@@ -1,4 +1,4 @@
1
- package com.reactlibrary;
1
+ package com.reactlibrary.core;
2
2
 
3
3
  import androidx.annotation.NonNull;
4
4
 
@@ -1,4 +1,4 @@
1
- package com.reactlibrary;
1
+ package com.reactlibrary.core;
2
2
 
3
3
  import androidx.annotation.NonNull;
4
4
 
@@ -13,7 +13,7 @@ import com.mapsindoors.core.MPSolutionDisplayRule;
13
13
  import com.mapsindoors.core.MapsIndoors;
14
14
  import com.mapsindoors.core.errors.MIError;
15
15
  import com.mapsindoors.core.errors.MIErrorEnum;
16
- import com.reactlibrary.models.MPError;
16
+ import com.reactlibrary.core.models.MPError;
17
17
 
18
18
  public class MPDisplayRuleModule extends ReactContextBaseJavaModule {
19
19
  private final Gson gson = new Gson();
@@ -649,8 +649,8 @@ public class MPDisplayRuleModule extends ReactContextBaseJavaModule {
649
649
  MPDisplayRule displayRule = getRule(displayRuleId);
650
650
  if (displayRule != null) {
651
651
  displayRule.setExtrusionZoomFrom(zoomFrom.floatValue());
652
- } else {
653
652
  promise.resolve(null);
653
+ } else {
654
654
  reject(promise, displayRuleId);
655
655
  }
656
656
  }
@@ -1,7 +1,5 @@
1
- package com.reactlibrary;
1
+ package com.reactlibrary.core;
2
2
 
3
- import android.app.Activity;
4
- import android.graphics.Typeface;
5
3
  import android.view.View;
6
4
 
7
5
  import androidx.annotation.NonNull;
@@ -17,14 +15,12 @@ import com.facebook.react.bridge.WritableMap;
17
15
  import com.facebook.react.modules.core.DeviceEventManagerModule;
18
16
  import com.google.gson.Gson;
19
17
  import com.google.gson.reflect.TypeToken;
20
- import com.mapbox.maps.CameraOptions;
21
- import com.mapbox.maps.MapView;
22
- import com.mapbox.maps.MapboxMap;
23
18
  import com.mapsindoors.core.MPBuilding;
24
19
  import com.mapsindoors.core.MPFilter;
25
20
  import com.mapsindoors.core.MPFilterBehavior;
26
21
  import com.mapsindoors.core.MPFloor;
27
22
  import com.mapsindoors.core.MPFloorSelectorInterface;
23
+ import com.mapsindoors.core.MPIMapConfig;
28
24
  import com.mapsindoors.core.MPLocation;
29
25
  import com.mapsindoors.core.MPPoint;
30
26
  import com.mapsindoors.core.MPSelectionBehavior;
@@ -39,12 +35,10 @@ import com.mapsindoors.core.errors.MIError;
39
35
  import com.mapsindoors.core.models.MPCameraEvent;
40
36
  import com.mapsindoors.core.models.MPCameraEventListener;
41
37
  import com.mapsindoors.core.models.MPMapStyle;
42
- import com.mapsindoors.mapbox.MPMapConfig;
43
- import com.reactlibrary.models.Filter;
44
- import com.reactlibrary.models.Location;
45
- import com.reactlibrary.models.MPCameraPosition;
46
- import com.reactlibrary.models.MPCameraUpdate;
47
- import com.reactlibrary.models.MPError;
38
+ import com.reactlibrary.core.models.Filter;
39
+ import com.reactlibrary.core.models.Location;
40
+ import com.reactlibrary.core.models.MPCameraUpdate;
41
+ import com.reactlibrary.core.models.MPError;
48
42
 
49
43
  import java.util.ArrayList;
50
44
  import java.util.HashMap;
@@ -52,8 +46,7 @@ import java.util.List;
52
46
  import java.util.Map;
53
47
 
54
48
  public class MapControlModule extends ReactContextBaseJavaModule implements MPCameraEventListener, OnFloorUpdateListener, MPFloorSelectorInterface {
55
- private MapboxMap mMap;
56
- private MapView mMapView;
49
+ private RCMapView mMapView;
57
50
  private final Gson gson = new Gson();
58
51
  private MapControl mMapControl;
59
52
  private OnMapControlReadyListener mcListener;
@@ -82,18 +75,14 @@ public class MapControlModule extends ReactContextBaseJavaModule implements MPCa
82
75
  mCtx.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(listener.method, data);
83
76
  }
84
77
 
85
- public void setMap(MapboxMap map) {
86
- mMap = map;
87
- }
88
-
89
- public void setView(MapView view) {
78
+ public void setView(RCMapView view) {
90
79
  mMapView = view;
91
80
  }
92
81
 
93
82
  @ReactMethod
94
83
  public void initMapControl(ReadableMap config, final Promise promise) {
95
84
  getCurrentActivity().runOnUiThread(()-> {
96
- MPMapConfig mpMapConfig = parseConfig(config, getCurrentActivity(), mMap, mCtx.getString(R.string.mapbox_api_key), mMapView);
85
+ MPIMapConfig mpMapConfig = mMapView.parseConfig(config, getCurrentActivity());
97
86
  MapControl.create(mpMapConfig, (mapControl, miError) -> {
98
87
  mcListener.onMapControlReady(mapControl,miError);
99
88
  if (mapControl != null) {
@@ -106,37 +95,6 @@ public class MapControlModule extends ReactContextBaseJavaModule implements MPCa
106
95
  });
107
96
  }
108
97
 
109
- private MPMapConfig parseConfig(ReadableMap configMap, Activity activity, MapboxMap map, String apiKey, MapView mapView) {
110
- boolean useDefaultStyle = !configMap.hasKey("useDefaultMapsIndoorsStyle") || configMap.getBoolean("useDefaultMapsIndoorsStyle");
111
- MPMapConfig.Builder config = new MPMapConfig.Builder(activity, map, mapView, apiKey, useDefaultStyle);
112
-
113
- if (configMap.hasKey("typeface")) {
114
- config.setMapLabelFont(Typeface.create("typeface", Typeface.NORMAL), configMap.getString("color"), configMap.getBoolean("showHalo"));
115
- }
116
-
117
- if (configMap.hasKey("textSize")) {
118
- config.setMapLabelTextSize(configMap.getInt("textSize"));
119
- }
120
-
121
- if (configMap.hasKey("showFloorSelector")) {
122
- config.setShowFloorSelector(configMap.getBoolean("showFloorSelector"));
123
- }
124
-
125
- if (configMap.hasKey("showInfoWindowOnClick")) {
126
- config.setShowInfoWindowOnLocationClicked(configMap.getBoolean("showInfoWindowOnClick"));
127
- }
128
-
129
- if (configMap.hasKey("showUserPosition")) {
130
- config.setShowUserPosition(configMap.getBoolean("showUserPosition"));
131
- }
132
-
133
- if (configMap.hasKey("enableTileFadeIn")) {
134
- config.setTileFadeInEnabled(configMap.getBoolean("enableTileFadeIn"));
135
- }
136
-
137
- return config.build();
138
- }
139
-
140
98
  @ReactMethod
141
99
  public void setFilterWithLocations(String locationsString, String filterBehaviorString, final Promise promise) {
142
100
  ArrayList<String> locationIds = gson.fromJson(locationsString, new TypeToken<List<String>>() {}.getType());
@@ -270,30 +228,35 @@ public class MapControlModule extends ReactContextBaseJavaModule implements MPCa
270
228
 
271
229
  @ReactMethod
272
230
  public void setMapPadding(int start, int top, int end, int bottom, final Promise promise) {
231
+ double density = mCtx.getResources().getDisplayMetrics().density;
273
232
  mCtx.runOnUiQueueThread(() -> {
274
- mMapControl.setMapPadding(start, top, end, bottom);
233
+ mMapControl.setMapPadding((int)Math.round(start * density), (int)Math.round(top * density), (int)Math.round(end * density), (int) Math.round(bottom * density));
275
234
  promise.resolve(null);
276
235
  });
277
236
  }
278
237
 
279
238
  @ReactMethod
280
239
  public void getMapViewPaddingStart(final Promise promise) {
281
- promise.resolve(mMapControl.getMapViewPaddingStart());
240
+ double density = mCtx.getResources().getDisplayMetrics().density;
241
+ promise.resolve((int)Math.round(mMapControl.getMapViewPaddingStart()/density));
282
242
  }
283
243
 
284
244
  @ReactMethod
285
245
  public void getMapViewPaddingTop(final Promise promise) {
286
- promise.resolve(mMapControl.getMapViewPaddingTop());
246
+ double density = mCtx.getResources().getDisplayMetrics().density;
247
+ promise.resolve((int)Math.round(mMapControl.getMapViewPaddingTop()/density));
287
248
  }
288
249
 
289
250
  @ReactMethod
290
251
  public void getMapViewPaddingEnd(final Promise promise) {
291
- promise.resolve(mMapControl.getMapViewPaddingEnd());
252
+ double density = mCtx.getResources().getDisplayMetrics().density;
253
+ promise.resolve((int)Math.round(mMapControl.getMapViewPaddingEnd()/density));
292
254
  }
293
255
 
294
256
  @ReactMethod
295
257
  public void getMapViewPaddingBottom(final Promise promise) {
296
- promise.resolve(mMapControl.getMapViewPaddingBottom());
258
+ double density = mCtx.getResources().getDisplayMetrics().density;
259
+ promise.resolve((int)Math.round(mMapControl.getMapViewPaddingBottom()/density));
297
260
  }
298
261
 
299
262
  @ReactMethod
@@ -355,8 +318,10 @@ public class MapControlModule extends ReactContextBaseJavaModule implements MPCa
355
318
 
356
319
  @ReactMethod
357
320
  public void hideFloorSelector(boolean hide, final Promise promise) {
358
- mMapControl.hideFloorSelector(hide);
359
- promise.resolve(null);
321
+ mCtx.runOnUiQueueThread(() -> {
322
+ mMapControl.hideFloorSelector(hide);
323
+ promise.resolve(null);
324
+ });
360
325
  }
361
326
 
362
327
  @ReactMethod
@@ -397,25 +362,27 @@ public class MapControlModule extends ReactContextBaseJavaModule implements MPCa
397
362
 
398
363
  @ReactMethod
399
364
  public void animateCamera(String updateString, @Nullable Integer duration, final Promise promise) {
400
- CameraOptions update = gson.fromJson(updateString, MPCameraUpdate.class).toCameraOptions(mMap);
365
+ MPCameraUpdate update = gson.fromJson(updateString, MPCameraUpdate.class);
401
366
  mCtx.runOnUiQueueThread(() -> {
402
- mMap.setCamera(update);
403
- promise.resolve(null);
367
+ // we have to parse null as -1 because iOS cannot parse null
368
+ mMapView.animateCamera(update, (duration == - 1 ? null : duration), error -> {
369
+ promise.resolve(null);
370
+ });
404
371
  });
405
372
  }
406
373
 
407
374
  @ReactMethod
408
375
  public void moveCamera(String updateString, final Promise promise) {
409
- CameraOptions update = gson.fromJson(updateString, MPCameraUpdate.class).toCameraOptions(mMap);
376
+ MPCameraUpdate update = gson.fromJson(updateString, MPCameraUpdate.class);
410
377
  mCtx.runOnUiQueueThread(() -> {
411
- mMap.setCamera(update);
378
+ mMapView.moveCamera(update);
412
379
  promise.resolve(null);
413
380
  });
414
381
  }
415
382
 
416
383
  @ReactMethod
417
384
  public void getCurrentCameraPosition(final Promise promise) {
418
- mCtx.runOnUiQueueThread(() -> promise.resolve(gson.toJson(new MPCameraPosition(mMap.getCameraState()))));
385
+ mCtx.runOnUiQueueThread(() -> promise.resolve(gson.toJson(mMapView.getCurrentCameraPosition())));
419
386
  }
420
387
 
421
388
  @ReactMethod
@@ -1,4 +1,4 @@
1
- package com.reactlibrary;
1
+ package com.reactlibrary.core;
2
2
 
3
3
  import com.facebook.react.bridge.Arguments;
4
4
  import com.facebook.react.bridge.Promise;
@@ -25,11 +25,11 @@ import com.mapsindoors.core.MPVenueCollection;
25
25
  import com.mapsindoors.core.MapsIndoors;
26
26
  import com.mapsindoors.core.errors.MIError;
27
27
  import com.mapsindoors.core.models.MPMapStyle;
28
- import com.reactlibrary.models.Filter;
29
- import com.reactlibrary.models.PositionProvider;
30
- import com.reactlibrary.models.PositionResult;
31
- import com.reactlibrary.models.Query;
32
- import com.reactlibrary.models.MPError;
28
+ import com.reactlibrary.core.models.Filter;
29
+ import com.reactlibrary.core.models.MPError;
30
+ import com.reactlibrary.core.models.PositionProvider;
31
+ import com.reactlibrary.core.models.PositionResult;
32
+ import com.reactlibrary.core.models.Query;
33
33
 
34
34
  import java.util.ArrayList;
35
35
  import java.util.List;
@@ -0,0 +1,16 @@
1
+ package com.reactlibrary.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.reactlibrary.core.models.MPCameraPosition;
9
+ import com.reactlibrary.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,92 @@
1
+ # react-native-mapsindoors-core-android
2
+
3
+
4
+
5
+ ## Getting started
6
+
7
+ To make it easy for you to get started with GitLab, here's a list of recommended next steps.
8
+
9
+ Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
10
+
11
+ ## Add your files
12
+
13
+ - [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
14
+ - [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
15
+
16
+ ```
17
+ cd existing_repo
18
+ git remote add origin https://git.rtx.mapspeople.com/timi/react-native-mapsindoors-core-android.git
19
+ git branch -M main
20
+ git push -uf origin main
21
+ ```
22
+
23
+ ## Integrate with your tools
24
+
25
+ - [ ] [Set up project integrations](https://git.rtx.mapspeople.com/timi/react-native-mapsindoors-core-android/-/settings/integrations)
26
+
27
+ ## Collaborate with your team
28
+
29
+ - [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
30
+ - [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
31
+ - [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
32
+ - [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
33
+ - [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
34
+
35
+ ## Test and Deploy
36
+
37
+ Use the built-in continuous integration in GitLab.
38
+
39
+ - [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
40
+ - [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
41
+ - [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
42
+ - [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
43
+ - [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
44
+
45
+ ***
46
+
47
+ # Editing this README
48
+
49
+ When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
50
+
51
+ ## Suggestions for a good README
52
+ Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
53
+
54
+ ## Name
55
+ Choose a self-explaining name for your project.
56
+
57
+ ## Description
58
+ Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
59
+
60
+ ## Badges
61
+ On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
62
+
63
+ ## Visuals
64
+ Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
65
+
66
+ ## Installation
67
+ Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
68
+
69
+ ## Usage
70
+ Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
71
+
72
+ ## Support
73
+ Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
74
+
75
+ ## Roadmap
76
+ If you have ideas for releases in the future, it is a good idea to list them in the README.
77
+
78
+ ## Contributing
79
+ State if you are open to contributions and what your requirements are for accepting them.
80
+
81
+ For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
82
+
83
+ You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
84
+
85
+ ## Authors and acknowledgment
86
+ Show your appreciation to those who have contributed to the project.
87
+
88
+ ## License
89
+ For open source projects, say how it is licensed.
90
+
91
+ ## Project status
92
+ If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.