@mapsindoors/react-native-maps-indoors-mapbox 0.0.5-beta

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 (147) hide show
  1. package/LICENSE +11 -0
  2. package/README.md +178 -0
  3. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  4. package/android/.gradle/7.4/checksums/md5-checksums.bin +0 -0
  5. package/android/.gradle/7.4/checksums/sha1-checksums.bin +0 -0
  6. package/android/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock +0 -0
  7. package/android/.gradle/7.4/dependencies-accessors/gc.properties +0 -0
  8. package/android/.gradle/7.4/executionHistory/executionHistory.bin +0 -0
  9. package/android/.gradle/7.4/executionHistory/executionHistory.lock +0 -0
  10. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  11. package/android/.gradle/7.4/fileHashes/fileHashes.bin +0 -0
  12. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  13. package/android/.gradle/7.4/fileHashes/resourceHashesCache.bin +0 -0
  14. package/android/.gradle/7.4/gc.properties +0 -0
  15. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  16. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  17. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  18. package/android/.gradle/file-system.probe +0 -0
  19. package/android/.gradle/vcs-1/gc.properties +0 -0
  20. package/android/.idea/compiler.xml +6 -0
  21. package/android/.idea/gradle.xml +19 -0
  22. package/android/.idea/jarRepositories.xml +45 -0
  23. package/android/.idea/misc.xml +10 -0
  24. package/android/.idea/vcs.xml +6 -0
  25. package/android/README.md +14 -0
  26. package/android/build.gradle +169 -0
  27. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  28. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  29. package/android/gradle.properties +17 -0
  30. package/android/gradlew +234 -0
  31. package/android/gradlew.bat +89 -0
  32. package/android/local.properties +8 -0
  33. package/android/src/main/AndroidManifest.xml +6 -0
  34. package/android/src/main/java/com/reactlibrary/DirectionsRendererModule.java +207 -0
  35. package/android/src/main/java/com/reactlibrary/DirectionsServiceModule.java +130 -0
  36. package/android/src/main/java/com/reactlibrary/MPDisplayRuleModule.java +816 -0
  37. package/android/src/main/java/com/reactlibrary/MapControlModule.java +661 -0
  38. package/android/src/main/java/com/reactlibrary/MapsIndoorsModule.java +327 -0
  39. package/android/src/main/java/com/reactlibrary/MapsIndoorsPackage.java +46 -0
  40. package/android/src/main/java/com/reactlibrary/MapsIndoorsViewManager.java +119 -0
  41. package/android/src/main/java/com/reactlibrary/UtilsModule.java +165 -0
  42. package/android/src/main/java/com/reactlibrary/models/Bounds.java +19 -0
  43. package/android/src/main/java/com/reactlibrary/models/Filter.java +77 -0
  44. package/android/src/main/java/com/reactlibrary/models/Location.java +17 -0
  45. package/android/src/main/java/com/reactlibrary/models/MPCameraPosition.java +29 -0
  46. package/android/src/main/java/com/reactlibrary/models/MPCameraUpdate.java +92 -0
  47. package/android/src/main/java/com/reactlibrary/models/MPError.java +38 -0
  48. package/android/src/main/java/com/reactlibrary/models/PositionProvider.java +46 -0
  49. package/android/src/main/java/com/reactlibrary/models/PositionResult.java +117 -0
  50. package/android/src/main/java/com/reactlibrary/models/Query.java +30 -0
  51. package/android/src/main/res/values/google_maps_api_key.xml +4 -0
  52. package/android/src/main/res/values/mapbox_api_key.xml +5 -0
  53. package/index.ts +184 -0
  54. package/ios/DirectionsRendererBridge.m +53 -0
  55. package/ios/DirectionsRendererModule.swift +187 -0
  56. package/ios/DirectionsServiceBridge.m +46 -0
  57. package/ios/DirectionsServiceModule.swift +149 -0
  58. package/ios/MPDisplayRuleBridge.m +410 -0
  59. package/ios/MPDisplayRuleModule.swift +845 -0
  60. package/ios/MapControlBridge.m +178 -0
  61. package/ios/MapControlModule.swift +602 -0
  62. package/ios/MapsIndoors.xcodeproj/project.pbxproj +318 -0
  63. package/ios/MapsIndoors.xcworkspace/contents.xcworkspacedata +7 -0
  64. package/ios/MapsIndoors.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  65. package/ios/MapsIndoorsBridge.m +98 -0
  66. package/ios/MapsIndoorsData.swift +203 -0
  67. package/ios/MapsIndoorsModule.swift +247 -0
  68. package/ios/MapsIndoorsViewManager.swift +30 -0
  69. package/ios/MapsIndoorsViewManagerBridge.m +9 -0
  70. package/ios/ReactPositionProvider.swift +25 -0
  71. package/ios/UtilsBridge.m +63 -0
  72. package/ios/UtilsModule.swift +146 -0
  73. package/ios/helpers.swift +57 -0
  74. package/ios/react-native-maps-indoors-Bridging-Header.h +6 -0
  75. package/package.json +52 -0
  76. package/react-native-maps-indoors-mapbox.podspec +30 -0
  77. package/src/EventNames.ts +21 -0
  78. package/src/MPBounds.ts +137 -0
  79. package/src/MPBuilding.ts +334 -0
  80. package/src/MPBuildingCollection.ts +57 -0
  81. package/src/MPBuildingInfo.ts +63 -0
  82. package/src/MPCameraEvent.ts +17 -0
  83. package/src/MPCameraEventListener.ts +17 -0
  84. package/src/MPCameraPosition.ts +83 -0
  85. package/src/MPCameraUpdate.ts +174 -0
  86. package/src/MPCameraViewFitMode.ts +21 -0
  87. package/src/MPCategory.ts +76 -0
  88. package/src/MPCategoryCollection.ts +62 -0
  89. package/src/MPCollection.ts +59 -0
  90. package/src/MPCollisionHandling.ts +12 -0
  91. package/src/MPDataField.ts +69 -0
  92. package/src/MPDirectionsRenderer.ts +194 -0
  93. package/src/MPDirectionsService.ts +119 -0
  94. package/src/MPDisplayRule.ts +1027 -0
  95. package/src/MPEntity.ts +60 -0
  96. package/src/MPEntityInfo.ts +28 -0
  97. package/src/MPError.ts +122 -0
  98. package/src/MPFilter.ts +168 -0
  99. package/src/MPFilterBehavior.ts +95 -0
  100. package/src/MPFloor.ts +170 -0
  101. package/src/MPFloorSelectorInterface.ts +63 -0
  102. package/src/MPGeometry.ts +91 -0
  103. package/src/MPHighway.ts +14 -0
  104. package/src/MPIconSize.ts +39 -0
  105. package/src/MPLocation.ts +386 -0
  106. package/src/MPLocationPropertyNames.ts +30 -0
  107. package/src/MPLocationType.ts +16 -0
  108. package/src/MPMapConfig.ts +211 -0
  109. package/src/MPMapStyle.ts +57 -0
  110. package/src/MPMultiPolygon.ts +205 -0
  111. package/src/MPPoint.ts +165 -0
  112. package/src/MPPolygon.ts +206 -0
  113. package/src/MPPositionProviderInterface.ts +45 -0
  114. package/src/MPPositionResultInterface.ts +42 -0
  115. package/src/MPPropertyData.ts +215 -0
  116. package/src/MPQuery.ts +69 -0
  117. package/src/MPRoute.ts +95 -0
  118. package/src/MPRouteCoordinate.ts +95 -0
  119. package/src/MPRouteLeg.ts +128 -0
  120. package/src/MPRouteProperty.ts +83 -0
  121. package/src/MPRouteStep.ts +176 -0
  122. package/src/MPSelectionBehavior.ts +93 -0
  123. package/src/MPSettings3D.ts +107 -0
  124. package/src/MPSize.ts +21 -0
  125. package/src/MPSolution.ts +180 -0
  126. package/src/MPSolutionConfig.ts +127 -0
  127. package/src/MPSolutionDisplayRule.ts +13 -0
  128. package/src/MPUserRole.ts +60 -0
  129. package/src/MPUserRoleCollection.ts +37 -0
  130. package/src/MPUtils.ts +157 -0
  131. package/src/MPVenue.ts +294 -0
  132. package/src/MPVenueCollection.ts +58 -0
  133. package/src/MPVenueInfo.ts +62 -0
  134. package/src/MapControl.ts +861 -0
  135. package/src/MapView.tsx +34 -0
  136. package/src/MapsIndoors.ts +530 -0
  137. package/src/OnBuildingFoundAtCameraTargetListener.ts +17 -0
  138. package/src/OnFloorSelectionChangedListener.ts +17 -0
  139. package/src/OnFloorUpdateListener.ts +16 -0
  140. package/src/OnLegSelectedListener.ts +17 -0
  141. package/src/OnLiveLocationUpdateListener.ts +17 -0
  142. package/src/OnLocationSelectedListener.ts +17 -0
  143. package/src/OnMapClickListener.ts +20 -0
  144. package/src/OnMarkerClickListener.ts +17 -0
  145. package/src/OnMarkerInfoWindowClickListener.ts +17 -0
  146. package/src/OnPositionUpdateListener.ts +17 -0
  147. package/src/OnVenueFoundAtCameraTargetListener.ts +17 -0
@@ -0,0 +1,234 @@
1
+ #!/bin/sh
2
+
3
+ #
4
+ # Copyright © 2015-2021 the original authors.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ ##############################################################################
20
+ #
21
+ # Gradle start up script for POSIX generated by Gradle.
22
+ #
23
+ # Important for running:
24
+ #
25
+ # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26
+ # noncompliant, but you have some other compliant shell such as ksh or
27
+ # bash, then to run this script, type that shell name before the whole
28
+ # command line, like:
29
+ #
30
+ # ksh Gradle
31
+ #
32
+ # Busybox and similar reduced shells will NOT work, because this script
33
+ # requires all of these POSIX shell features:
34
+ # * functions;
35
+ # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36
+ # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37
+ # * compound commands having a testable exit status, especially «case»;
38
+ # * various built-in commands including «command», «set», and «ulimit».
39
+ #
40
+ # Important for patching:
41
+ #
42
+ # (2) This script targets any POSIX shell, so it avoids extensions provided
43
+ # by Bash, Ksh, etc; in particular arrays are avoided.
44
+ #
45
+ # The "traditional" practice of packing multiple parameters into a
46
+ # space-separated string is a well documented source of bugs and security
47
+ # problems, so this is (mostly) avoided, by progressively accumulating
48
+ # options in "$@", and eventually passing that to Java.
49
+ #
50
+ # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51
+ # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52
+ # see the in-line comments for details.
53
+ #
54
+ # There are tweaks for specific operating systems such as AIX, CygWin,
55
+ # Darwin, MinGW, and NonStop.
56
+ #
57
+ # (3) This script is generated from the Groovy template
58
+ # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59
+ # within the Gradle project.
60
+ #
61
+ # You can find Gradle at https://github.com/gradle/gradle/.
62
+ #
63
+ ##############################################################################
64
+
65
+ # Attempt to set APP_HOME
66
+
67
+ # Resolve links: $0 may be a link
68
+ app_path=$0
69
+
70
+ # Need this for daisy-chained symlinks.
71
+ while
72
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73
+ [ -h "$app_path" ]
74
+ do
75
+ ls=$( ls -ld "$app_path" )
76
+ link=${ls#*' -> '}
77
+ case $link in #(
78
+ /*) app_path=$link ;; #(
79
+ *) app_path=$APP_HOME$link ;;
80
+ esac
81
+ done
82
+
83
+ APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84
+
85
+ APP_NAME="Gradle"
86
+ APP_BASE_NAME=${0##*/}
87
+
88
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89
+ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90
+
91
+ # Use the maximum available, or set MAX_FD != -1 to use that value.
92
+ MAX_FD=maximum
93
+
94
+ warn () {
95
+ echo "$*"
96
+ } >&2
97
+
98
+ die () {
99
+ echo
100
+ echo "$*"
101
+ echo
102
+ exit 1
103
+ } >&2
104
+
105
+ # OS specific support (must be 'true' or 'false').
106
+ cygwin=false
107
+ msys=false
108
+ darwin=false
109
+ nonstop=false
110
+ case "$( uname )" in #(
111
+ CYGWIN* ) cygwin=true ;; #(
112
+ Darwin* ) darwin=true ;; #(
113
+ MSYS* | MINGW* ) msys=true ;; #(
114
+ NONSTOP* ) nonstop=true ;;
115
+ esac
116
+
117
+ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118
+
119
+
120
+ # Determine the Java command to use to start the JVM.
121
+ if [ -n "$JAVA_HOME" ] ; then
122
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123
+ # IBM's JDK on AIX uses strange locations for the executables
124
+ JAVACMD=$JAVA_HOME/jre/sh/java
125
+ else
126
+ JAVACMD=$JAVA_HOME/bin/java
127
+ fi
128
+ if [ ! -x "$JAVACMD" ] ; then
129
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130
+
131
+ Please set the JAVA_HOME variable in your environment to match the
132
+ location of your Java installation."
133
+ fi
134
+ else
135
+ JAVACMD=java
136
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137
+
138
+ Please set the JAVA_HOME variable in your environment to match the
139
+ location of your Java installation."
140
+ fi
141
+
142
+ # Increase the maximum file descriptors if we can.
143
+ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144
+ case $MAX_FD in #(
145
+ max*)
146
+ MAX_FD=$( ulimit -H -n ) ||
147
+ warn "Could not query maximum file descriptor limit"
148
+ esac
149
+ case $MAX_FD in #(
150
+ '' | soft) :;; #(
151
+ *)
152
+ ulimit -n "$MAX_FD" ||
153
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
154
+ esac
155
+ fi
156
+
157
+ # Collect all arguments for the java command, stacking in reverse order:
158
+ # * args from the command line
159
+ # * the main class name
160
+ # * -classpath
161
+ # * -D...appname settings
162
+ # * --module-path (only if needed)
163
+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
164
+
165
+ # For Cygwin or MSYS, switch paths to Windows format before running java
166
+ if "$cygwin" || "$msys" ; then
167
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
168
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
169
+
170
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
171
+
172
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
173
+ for arg do
174
+ if
175
+ case $arg in #(
176
+ -*) false ;; # don't mess with options #(
177
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
178
+ [ -e "$t" ] ;; #(
179
+ *) false ;;
180
+ esac
181
+ then
182
+ arg=$( cygpath --path --ignore --mixed "$arg" )
183
+ fi
184
+ # Roll the args list around exactly as many times as the number of
185
+ # args, so each arg winds up back in the position where it started, but
186
+ # possibly modified.
187
+ #
188
+ # NB: a `for` loop captures its iteration list before it begins, so
189
+ # changing the positional parameters here affects neither the number of
190
+ # iterations, nor the values presented in `arg`.
191
+ shift # remove old arg
192
+ set -- "$@" "$arg" # push replacement arg
193
+ done
194
+ fi
195
+
196
+ # Collect all arguments for the java command;
197
+ # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198
+ # shell script including quotes and variable substitutions, so put them in
199
+ # double quotes to make sure that they get re-expanded; and
200
+ # * put everything else in single quotes, so that it's not re-expanded.
201
+
202
+ set -- \
203
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
204
+ -classpath "$CLASSPATH" \
205
+ org.gradle.wrapper.GradleWrapperMain \
206
+ "$@"
207
+
208
+ # Use "xargs" to parse quoted args.
209
+ #
210
+ # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
211
+ #
212
+ # In Bash we could simply go:
213
+ #
214
+ # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
215
+ # set -- "${ARGS[@]}" "$@"
216
+ #
217
+ # but POSIX shell has neither arrays nor command substitution, so instead we
218
+ # post-process each arg (as a line of input to sed) to backslash-escape any
219
+ # character that might be a shell metacharacter, then use eval to reverse
220
+ # that process (while maintaining the separation between arguments), and wrap
221
+ # the whole thing up as a single "set" statement.
222
+ #
223
+ # This will of course break if any of these variables contains a newline or
224
+ # an unmatched quote.
225
+ #
226
+
227
+ eval "set -- $(
228
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
229
+ xargs -n1 |
230
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
231
+ tr '\n' ' '
232
+ )" '"$@"'
233
+
234
+ exec "$JAVACMD" "$@"
@@ -0,0 +1,89 @@
1
+ @rem
2
+ @rem Copyright 2015 the original author or authors.
3
+ @rem
4
+ @rem Licensed under the Apache License, Version 2.0 (the "License");
5
+ @rem you may not use this file except in compliance with the License.
6
+ @rem You may obtain a copy of the License at
7
+ @rem
8
+ @rem https://www.apache.org/licenses/LICENSE-2.0
9
+ @rem
10
+ @rem Unless required by applicable law or agreed to in writing, software
11
+ @rem distributed under the License is distributed on an "AS IS" BASIS,
12
+ @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ @rem See the License for the specific language governing permissions and
14
+ @rem limitations under the License.
15
+ @rem
16
+
17
+ @if "%DEBUG%" == "" @echo off
18
+ @rem ##########################################################################
19
+ @rem
20
+ @rem Gradle startup script for Windows
21
+ @rem
22
+ @rem ##########################################################################
23
+
24
+ @rem Set local scope for the variables with windows NT shell
25
+ if "%OS%"=="Windows_NT" setlocal
26
+
27
+ set DIRNAME=%~dp0
28
+ if "%DIRNAME%" == "" set DIRNAME=.
29
+ set APP_BASE_NAME=%~n0
30
+ set APP_HOME=%DIRNAME%
31
+
32
+ @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33
+ for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34
+
35
+ @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36
+ set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37
+
38
+ @rem Find java.exe
39
+ if defined JAVA_HOME goto findJavaFromJavaHome
40
+
41
+ set JAVA_EXE=java.exe
42
+ %JAVA_EXE% -version >NUL 2>&1
43
+ if "%ERRORLEVEL%" == "0" goto execute
44
+
45
+ echo.
46
+ echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47
+ echo.
48
+ echo Please set the JAVA_HOME variable in your environment to match the
49
+ echo location of your Java installation.
50
+
51
+ goto fail
52
+
53
+ :findJavaFromJavaHome
54
+ set JAVA_HOME=%JAVA_HOME:"=%
55
+ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56
+
57
+ if exist "%JAVA_EXE%" goto execute
58
+
59
+ echo.
60
+ echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61
+ echo.
62
+ echo Please set the JAVA_HOME variable in your environment to match the
63
+ echo location of your Java installation.
64
+
65
+ goto fail
66
+
67
+ :execute
68
+ @rem Setup the command line
69
+
70
+ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71
+
72
+
73
+ @rem Execute Gradle
74
+ "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75
+
76
+ :end
77
+ @rem End local scope for the variables with windows NT shell
78
+ if "%ERRORLEVEL%"=="0" goto mainEnd
79
+
80
+ :fail
81
+ rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82
+ rem the _cmd.exe /c_ return code!
83
+ if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84
+ exit /b 1
85
+
86
+ :mainEnd
87
+ if "%OS%"=="Windows_NT" endlocal
88
+
89
+ :omega
@@ -0,0 +1,8 @@
1
+ ## This file must *NOT* be checked into Version Control Systems,
2
+ # as it contains information specific to your local configuration.
3
+ #
4
+ # Location of the SDK. This is only used by Gradle.
5
+ # For customization when using a Version Control System, please read the
6
+ # header note.
7
+ #Thu Feb 02 14:40:07 CET 2023
8
+ sdk.dir=/Users/timmikkelsen/Library/Android/sdk
@@ -0,0 +1,6 @@
1
+ <!-- AndroidManifest.xml -->
2
+
3
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
4
+ package="com.reactlibrary">
5
+
6
+ </manifest>
@@ -0,0 +1,207 @@
1
+ package com.reactlibrary;
2
+
3
+ import android.graphics.Color;
4
+
5
+ import androidx.annotation.NonNull;
6
+ import androidx.annotation.Nullable;
7
+
8
+ import com.facebook.react.bridge.Arguments;
9
+ import com.facebook.react.bridge.Promise;
10
+ import com.facebook.react.bridge.ReactApplicationContext;
11
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
12
+ import com.facebook.react.bridge.ReactMethod;
13
+ import com.facebook.react.bridge.WritableMap;
14
+ import com.facebook.react.modules.core.DeviceEventManagerModule;
15
+ import com.google.gson.Gson;
16
+ import com.mapsindoors.core.MPCameraViewFitMode;
17
+ import com.mapsindoors.core.MPDirectionsRenderer;
18
+ import com.mapsindoors.core.MPRoute;
19
+ import com.mapsindoors.core.MapControl;
20
+ import com.mapsindoors.core.OnMapControlReadyListener;
21
+ import com.mapsindoors.core.errors.MIError;
22
+ import com.mapsindoors.core.errors.MIErrorEnum;
23
+ import com.mapsindoors.core.errors.MapsIndoorsException;
24
+ import com.reactlibrary.models.MPError;
25
+
26
+ public class DirectionsRendererModule extends ReactContextBaseJavaModule implements OnMapControlReadyListener {
27
+ private MapControl mMapControl;
28
+ private MPDirectionsRenderer mRenderer;
29
+ private final ReactApplicationContext mCtx;
30
+
31
+ public DirectionsRendererModule(@NonNull ReactApplicationContext reactContext, MapControlModule mapControl) {
32
+ super(reactContext);
33
+ mapControl.setOnMapControlReadyListener(this);
34
+ mCtx = reactContext;
35
+ }
36
+
37
+ @NonNull
38
+ @Override
39
+ public String getName() {
40
+ return "DirectionsRenderer";
41
+ }
42
+
43
+ private void rejectPromise(Promise promise) {
44
+ promise.reject("Renderer not initialized", new MapsIndoorsException("Renderer not initialized"));
45
+ }
46
+
47
+ @ReactMethod
48
+ public void clear(final Promise promise) {
49
+ if (mRenderer != null) {
50
+ mRenderer.clear();
51
+ promise.resolve(null);
52
+ } else {
53
+ rejectPromise(promise);
54
+ }
55
+ }
56
+
57
+ @ReactMethod
58
+ public void getSelectedLegFloorIndex(final Promise promise) {
59
+ if (mRenderer != null) {
60
+ promise.resolve(mRenderer.getSelectedLegFloorIndex());
61
+ } else {
62
+ rejectPromise(promise);
63
+ }
64
+ }
65
+
66
+ @ReactMethod
67
+ public void nextLeg(final Promise promise) {
68
+ if (mRenderer != null) {
69
+ mRenderer.nextLeg();
70
+ promise.resolve(null);
71
+ } else {
72
+ rejectPromise(promise);
73
+ }
74
+ }
75
+
76
+ @ReactMethod
77
+ public void previousLeg(final Promise promise) {
78
+ if (mRenderer != null) {
79
+ mRenderer.previousLeg();
80
+ promise.resolve(null);
81
+ } else {
82
+ rejectPromise(promise);
83
+ }
84
+ }
85
+
86
+ @ReactMethod
87
+ public void selectLegIndex(int legIndex, final Promise promise) {
88
+ if (mRenderer != null) {
89
+ try {
90
+ mRenderer.selectLegIndex(legIndex);
91
+ } catch (IllegalStateException e) {
92
+ promise.reject(e.getMessage(), new Gson().toJson(MPError.fromMIError(new MIError(MIErrorEnum.ROUTING_UNKNOWN_ERROR, e.getMessage()))));
93
+ return;
94
+ }
95
+ promise.resolve(null);
96
+ } else {
97
+ rejectPromise(promise);
98
+ }
99
+ }
100
+
101
+ @ReactMethod
102
+ public void setAnimatedPolyline(boolean animated, boolean repeated, int duration, final Promise promise) {
103
+ if (mRenderer != null) {
104
+ mRenderer.setAnimatedPolyline(animated, repeated, duration);
105
+ promise.resolve(null);
106
+ } else {
107
+ rejectPromise(promise);
108
+ }
109
+ }
110
+
111
+ @ReactMethod
112
+ public void setCameraAnimationDuration(int duration, final Promise promise) {
113
+ if (mRenderer != null) {
114
+ mRenderer.setCameraAnimationDuration(duration);
115
+ promise.resolve(null);
116
+ } else {
117
+ rejectPromise(promise);
118
+ }
119
+ }
120
+
121
+ @ReactMethod
122
+ public void setCameraViewFitMode(int cameraFitMode, final Promise promise) {
123
+ if (mRenderer != null) {
124
+ final MPCameraViewFitMode mode;
125
+ switch (cameraFitMode) {
126
+ case 0:
127
+ mode = MPCameraViewFitMode.NORTH_ALIGNED;
128
+ break;
129
+ case 1:
130
+ mode = MPCameraViewFitMode.FIRST_STEP_ALIGNED;
131
+ break;
132
+ case 2:
133
+ mode = MPCameraViewFitMode.START_TO_END_ALIGNED;
134
+ break;
135
+ default:
136
+ mode = null;
137
+ }
138
+ if (mode != null) {
139
+ mRenderer.setCameraViewFitMode(mode);
140
+ }
141
+ promise.resolve(null);
142
+ } else {
143
+ rejectPromise(promise);
144
+ }
145
+ }
146
+
147
+ @ReactMethod
148
+ public void setOnLegSelectedListener(final Promise promise) {
149
+ if (mRenderer != null) {
150
+ mRenderer.setOnLegSelectedListener(leg -> {
151
+ WritableMap params = Arguments.createMap();
152
+ params.putInt("leg", leg);
153
+ mCtx.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("onLegSelected", params);
154
+ });
155
+ promise.resolve(null);
156
+ } else {
157
+ rejectPromise(promise);
158
+ }
159
+ }
160
+
161
+ @ReactMethod
162
+ public void setPolyLineColors(String foregroundString, String backgroundString, final Promise promise) {
163
+ if (mRenderer != null) {
164
+ int foreground;
165
+ int background;
166
+ try {
167
+ foreground = Color.parseColor(foregroundString);
168
+ background = Color.parseColor(backgroundString);
169
+ } catch (IllegalArgumentException e) {
170
+ promise.reject(e);
171
+ return;
172
+ }
173
+ mRenderer.setPolylineColors(foreground, background);
174
+ promise.resolve(null);
175
+ } else {
176
+ rejectPromise(promise);
177
+ }
178
+ }
179
+
180
+ @ReactMethod
181
+ public void setRoute(String routeString, final Promise promise) {
182
+ if (mRenderer != null) {
183
+ MPRoute route = new Gson().fromJson(routeString, MPRoute.class);
184
+ mRenderer.setRoute(route);
185
+ promise.resolve(null);
186
+ } else {
187
+ rejectPromise(promise);
188
+ }
189
+ }
190
+
191
+ @Override
192
+ public void onMapControlReady(@Nullable MapControl mapControl, @Nullable MIError miError) {
193
+ if (mapControl != null) {
194
+ mMapControl = mapControl;
195
+ mRenderer = new MPDirectionsRenderer(mMapControl);
196
+ }
197
+ }
198
+
199
+ @ReactMethod
200
+ public void addListener(String eventName) {
201
+ // we are handling listeners ourselves
202
+ }
203
+ @ReactMethod
204
+ public void removeListeners(Integer count) {
205
+ // we are handling listeners ourselves
206
+ }
207
+ }
@@ -0,0 +1,130 @@
1
+ package com.reactlibrary;
2
+
3
+ import androidx.annotation.NonNull;
4
+
5
+ import com.facebook.react.bridge.Arguments;
6
+ import com.facebook.react.bridge.Promise;
7
+ import com.facebook.react.bridge.ReactApplicationContext;
8
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
9
+ import com.facebook.react.bridge.ReactMethod;
10
+ import com.facebook.react.bridge.WritableMap;
11
+ import com.google.gson.Gson;
12
+ import com.mapsindoors.core.MPDirectionsService;
13
+ import com.mapsindoors.core.MPPoint;
14
+ import com.mapsindoors.core.errors.MapsIndoorsException;
15
+
16
+ import java.util.Date;
17
+ import java.util.HashMap;
18
+ import java.util.UUID;
19
+
20
+ public class DirectionsServiceModule extends ReactContextBaseJavaModule {
21
+
22
+ private HashMap<String, MPDirectionsService> serviceMap = new HashMap<>();
23
+ private static final String NO_DS = "This DirectionsService is not available";
24
+
25
+ private final Gson gson = new Gson();
26
+ public DirectionsServiceModule(@NonNull ReactApplicationContext reactContext) {
27
+ super(reactContext);
28
+ }
29
+
30
+ @ReactMethod
31
+ public void create(final Promise promise) {
32
+ MPDirectionsService service = new MPDirectionsService();
33
+ String uuid = UUID.randomUUID().toString();
34
+ serviceMap.put(uuid, service);
35
+ promise.resolve(uuid);
36
+ }
37
+
38
+ @ReactMethod
39
+ public void addAvoidWayType(String wayType, final String id, final Promise promise) {
40
+ MPDirectionsService service = serviceMap.get(id);
41
+ if (service != null) {
42
+ service.addAvoidWayType(wayType);
43
+ promise.resolve(null);
44
+ } else {
45
+ promise.reject(NO_DS,new MapsIndoorsException((NO_DS)));
46
+ }
47
+ }
48
+
49
+ @ReactMethod
50
+ public void clearWayType(final String id, final Promise promise) {
51
+ MPDirectionsService service = serviceMap.get(id);
52
+ if (service != null) {
53
+ service.clearWayType();
54
+ promise.resolve(null);
55
+ } else {
56
+ promise.reject(NO_DS,new MapsIndoorsException((NO_DS)));
57
+ }
58
+ }
59
+
60
+ @ReactMethod
61
+ public void setIsDeparture(boolean isDeparture, final String id, final Promise promise) {
62
+ MPDirectionsService service = serviceMap.get(id);
63
+ if (service != null) {
64
+ service.setIsDeparture(isDeparture);
65
+ promise.resolve(null);
66
+ } else {
67
+ promise.reject(NO_DS,new MapsIndoorsException((NO_DS)));
68
+ }
69
+ }
70
+
71
+ @ReactMethod
72
+ public void getRoute(String originString, String destinationString, final String id, final Promise promise) {
73
+ MPDirectionsService service = serviceMap.get(id);
74
+ if (service != null) {
75
+ service.setRouteResultListener((route, error) -> {
76
+ WritableMap map = Arguments.createMap();
77
+ if (route != null) {
78
+ map.putString("route", gson.toJson(route));
79
+ }
80
+ if (error != null) {
81
+ map.putString("error", gson.toJson(error));
82
+ }
83
+ promise.resolve(map);
84
+ });
85
+ MPPoint origin = gson.fromJson(originString, MPPoint.class);
86
+ MPPoint destination = gson.fromJson(destinationString, MPPoint.class);
87
+
88
+ if (origin != null && destination != null) {
89
+ service.query(origin, destination);
90
+ } else {
91
+ promise.reject(new MapsIndoorsException("Origin:" + originString +
92
+ ", or Destination:" + destinationString + ", are not parsable"));
93
+ }
94
+ } else {
95
+ promise.reject(NO_DS,new MapsIndoorsException((NO_DS)));
96
+ }
97
+
98
+ }
99
+
100
+ @ReactMethod
101
+ public void setTravelMode(String travelMode, final String id, final Promise promise) {
102
+ MPDirectionsService service = serviceMap.get(id);
103
+ if (service != null) {
104
+ service.setTravelMode(travelMode);
105
+ promise.resolve(null);
106
+ } else {
107
+ promise.reject(NO_DS,new MapsIndoorsException((NO_DS)));
108
+ }
109
+ }
110
+
111
+ @ReactMethod
112
+ public void setTime(int time, final String id, final Promise promise) {
113
+ MPDirectionsService service = serviceMap.get(id);
114
+ if (service != null) {
115
+ Date date = new Date();
116
+ date.setTime(time);
117
+ service.setTime(date);
118
+ promise.resolve(null);
119
+ } else {
120
+ promise.reject(NO_DS,new MapsIndoorsException((NO_DS)));
121
+ }
122
+
123
+ }
124
+
125
+ @NonNull
126
+ @Override
127
+ public String getName() {
128
+ return "DirectionsService";
129
+ }
130
+ }