@mapsindoors/react-native-maps-indoors-mapbox 2.9.0 → 2.10.0
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/README.md +81 -21
- package/android/build.gradle +2 -14
- package/android/src/main/java/com/mapsindoorsrn/MapboxMapView.java +4 -0
- package/android/src/main/java/com/mapsindoorsrn/MapsIndoorsPackage.java +10 -1
- package/android/src/main/java/com/mapsindoorsrn/MapsIndoorsViewManager.java +28 -2
- package/android/src/main/java/com/mapsindoorsrn/core/DirectionsRendererModule.java +10 -2
- package/android/src/main/java/com/mapsindoorsrn/core/DirectionsServiceModule.java +1 -0
- package/android/src/main/java/com/mapsindoorsrn/core/MapControlModule.java +335 -99
- package/android/src/main/java/com/mapsindoorsrn/core/MapsIndoorsModule.java +17 -1
- package/android/src/main/java/com/mapsindoorsrn/core/RouteStore.java +59 -0
- package/app.plugin.js +8 -86
- package/ios/core/DirectionsRendererBridge.m +1 -0
- package/ios/core/DirectionsRendererModule.swift +292 -308
- package/ios/core/DirectionsServiceModule.swift +7 -1
- package/ios/core/MapControlModule.swift +330 -244
- package/ios/core/MapsIndoorsBridge.m +1 -0
- package/ios/core/MapsIndoorsModule.swift +48 -14
- package/ios/core/ReactPositionProvider.swift +6 -7
- package/ios/core/Sources/MainThread/CallGeneration.swift +38 -0
- package/ios/core/Sources/MainThread/MainThread.swift +25 -0
- package/ios/core/Sources/RouteStore/RouteStore.swift +62 -0
- package/package.json +10 -2
- package/react-native-maps-indoors-mapbox.podspec +6 -2
- package/specs/NativeDirectionsRendererModule.ts +1 -1
- package/specs/NativeMapsIndoorsModule.ts +1 -1
- package/src/core/MPCameraPosition.ts +1 -1
- package/src/core/MPDirectionsRenderer.ts +19 -3
- package/src/core/MPDirectionsService.ts +4 -1
- package/src/core/MPRouteStopIconConfig.ts +5 -3
- package/src/core/MapsIndoors.ts +36 -3
- package/src/core/RouteHandles.ts +76 -0
- package/src/core/RouteStopIconConfig.ts +5 -1
- package/src/core/__tests__/MPBounds.test.ts +0 -109
- package/src/core/__tests__/MPFilter.test.ts +0 -76
- package/src/core/__tests__/MPLanguageTag.test.ts +0 -168
- package/src/core/__tests__/MPPoint.test.ts +0 -82
- package/src/core/__tests__/MPSolution.test.ts +0 -107
- package/src/core/__tests__/MapsIndoors.language.test.ts +0 -180
package/README.md
CHANGED
|
@@ -2,11 +2,86 @@
|
|
|
2
2
|
|
|
3
3
|
## Documentation
|
|
4
4
|
|
|
5
|
-
Visit [our reference document site](https://app.mapsindoors.com/mapsindoors/reference/react-native/mapbox/2.
|
|
5
|
+
Visit [our reference document site](https://app.mapsindoors.com/mapsindoors/reference/react-native/mapbox/2.10.0/index.html) to get an overview of what the MapsIndoors SDK offers.
|
|
6
6
|
|
|
7
7
|
## Changelog
|
|
8
8
|
|
|
9
|
-
### [2.
|
|
9
|
+
### [2.10.0] - 2026-11-02
|
|
10
|
+
|
|
11
|
+
#### Added
|
|
12
|
+
|
|
13
|
+
- MapsIndoors Insights now attributes sessions from this package to its own component -
|
|
14
|
+
`React Native/android SDK` or `React Native/iOS SDK`, with the package's published version -
|
|
15
|
+
instead of reporting them as the plain native SDK. The version travels on `MapsIndoors.load`,
|
|
16
|
+
which is when the native SDK starts the session and snapshots the component, so the first session
|
|
17
|
+
after a cold start is attributed too
|
|
18
|
+
|
|
19
|
+
#### Changed
|
|
20
|
+
|
|
21
|
+
- No Mapbox download token is needed any more (Mapbox SDK 11.8+ downloads are public). The Expo
|
|
22
|
+
plugin ignores `downloadToken`, warns when it is set, and no longer writes
|
|
23
|
+
`MAPBOX_DOWNLOADS_TOKEN` to `gradle.properties` or credentials to `~/.netrc`. The Mapbox Maven
|
|
24
|
+
repository is added without credentials
|
|
25
|
+
- `MapControl.getCurrentFloorIndex`, `getCurrentMapsIndoorsZoom`, `isFloorSelectorHidden` and
|
|
26
|
+
`isUserPositionShown` reject when there is no map control. iOS resolved `null`, which reads as a
|
|
27
|
+
real floor index, zoom or `false`; Android crashed
|
|
28
|
+
|
|
29
|
+
#### Fixed
|
|
30
|
+
|
|
31
|
+
- On iOS, the blue dot now shows for a JavaScript position provider whose results leave out
|
|
32
|
+
`floorIndex`. Every such update was rejected, silently
|
|
33
|
+
- On iOS, the blue dot now shows for a position provider set after calling `MapsIndoors.load` again
|
|
34
|
+
while the map stays mounted
|
|
35
|
+
- Expo builds without `downloadToken` no longer fail to download Mapbox. The plugin wrote
|
|
36
|
+
`undefined` as the token to `gradle.properties` and `~/.netrc`, which Mapbox rejects with 401.
|
|
37
|
+
If an earlier plugin version wrote one, remove the `machine api.mapbox.com` entry from `~/.netrc`
|
|
38
|
+
- Opening and closing a map no longer leaks memory on every visit. On iOS, setting a position
|
|
39
|
+
provider kept the map alive in a retain cycle. On Android, the map's `MapControl` was never
|
|
40
|
+
destroyed and a layout callback kept running for good, so each map stayed in memory; the
|
|
41
|
+
`MapControl` is now destroyed with its map view. Without one, Android `MapControl` calls now
|
|
42
|
+
reject, resolve `null` or do nothing, as on iOS, instead of crashing
|
|
43
|
+
- On Android, `MapControl.clearFilter`, `clearHighlight` and `showUserPosition` resolve when there is
|
|
44
|
+
no map control, instead of never settling
|
|
45
|
+
- MapsIndoors Insights `directions_started` and `directions_completed` events now carry the
|
|
46
|
+
route's origin and destination location and venue, as from native apps. Requires a route
|
|
47
|
+
`MPDirectionsService.getRoute` returned since the last `MapsIndoors.load`, among the ten most
|
|
48
|
+
recently used; a copy made through JSON qualifies, an edited route does not
|
|
49
|
+
|
|
50
|
+
### [2.9.1] - 2026-10-16
|
|
51
|
+
|
|
52
|
+
#### Changed
|
|
53
|
+
|
|
54
|
+
- `MPRouteStopIconConfig.getImage()` returns a string instead of a `URL`, and a custom
|
|
55
|
+
`RouteStopIconConfig.getImage()` may return either
|
|
56
|
+
- Updated the MapsIndoors Android and iOS SDKs to 4.23.0
|
|
57
|
+
- On iOS, camera moves the SDK makes for you (`goTo`, selecting with `moveCamera`, filter, highlight
|
|
58
|
+
and route fits) are instant when the system's Reduce Motion setting is on
|
|
59
|
+
- On Android, with a custom floor selector that turns automatic floor changes off, `goTo`,
|
|
60
|
+
`selectLocation`, `setFilter` and `setHighlight` keep the current floor
|
|
61
|
+
- On iOS, `MapControl` and `MPDirectionsRenderer` promises settle once the map has applied the call,
|
|
62
|
+
not before
|
|
63
|
+
- On iOS, the `MapControl.getCurrent*` getters and `isFloorSelectorHidden` resolve `null` when there
|
|
64
|
+
is no map control, instead of crashing
|
|
65
|
+
- On iOS, `MPDirectionsRenderer.setRoute` and `setDefaultRouteStopIcon` reject when a URL icon fails
|
|
66
|
+
to download, instead of never settling
|
|
67
|
+
|
|
68
|
+
#### Fixed
|
|
69
|
+
|
|
70
|
+
- `MPDirectionsRenderer.setDefaultRouteStopIcon` and `setRoute` rejected an `MPRouteStopIconConfig`
|
|
71
|
+
stop icon with "Invalid URL" on React Native versions with a standards-compliant `URL`, such as
|
|
72
|
+
Expo 55, so the icon never reached the map. Labels containing `?` or `#` now work too
|
|
73
|
+
- Setting `MapControl.showUserPosition` no longer crashes the app on iOS. The iOS SDK now accepts
|
|
74
|
+
the call from React Native's module thread, where 4.20.0 required the main thread
|
|
75
|
+
- `MapControl` and `MPDirectionsRenderer` calls no longer crash the app on iOS. They now reach the map
|
|
76
|
+
on the main thread, in the order they were made
|
|
77
|
+
- `MPDirectionsRenderer.setRoute` and `setDefaultRouteStopIcon` with URL icons no longer overwrite a
|
|
78
|
+
later `setRoute`, `clear` or `setDefaultRouteStopIcon` when their download finishes last
|
|
79
|
+
- The published package no longer contains the core unit tests (`src/core/__tests__`)
|
|
80
|
+
- `MPCameraPosition.create` no longer swaps tilt and bearing, so reading the camera with
|
|
81
|
+
`getCurrentCameraPosition` and passing the result back to `animateCamera` keeps the map's pitch
|
|
82
|
+
and rotation
|
|
83
|
+
|
|
84
|
+
### [2.9.0] - 2026-09-18
|
|
10
85
|
|
|
11
86
|
#### Added
|
|
12
87
|
|
|
@@ -145,8 +220,7 @@ end
|
|
|
145
220
|
|
|
146
221
|
#### Providing API key
|
|
147
222
|
|
|
148
|
-
|
|
149
|
-
2. Setup your secret access token for downloading the sdk. Read how to do this here: [Configure credentials](https://docs.mapbox.com/ios/maps/guides/install/#configure-credentials)
|
|
223
|
+
Navigate to your application settings and add your Mapbox public access token to info with the key `MBXAccessToken`
|
|
150
224
|
|
|
151
225
|
### Android
|
|
152
226
|
|
|
@@ -174,9 +248,8 @@ To get the underlying Mapbox to function, you need to perform the following step
|
|
|
174
248
|
|
|
175
249
|
The plugin Gradle project has trouble resolving the MapsIndoors dependency, so to ensure that it is resolved correctly, do the following:
|
|
176
250
|
|
|
177
|
-
1. Navigate to the app
|
|
178
|
-
2.
|
|
179
|
-
3. add `maven { url 'https://maven.mapsindoors.com/' }` to `allprojects`/`repositories` as well as the Mapbox maven
|
|
251
|
+
1. Navigate to the app's project level `build.gradle`.
|
|
252
|
+
2. add `maven { url 'https://maven.mapsindoors.com/' }` to `allprojects`/`repositories` as well as the Mapbox maven
|
|
180
253
|
|
|
181
254
|
|
|
182
255
|
```groovy
|
|
@@ -185,19 +258,7 @@ allprojects {
|
|
|
185
258
|
google()
|
|
186
259
|
mavenCentral()
|
|
187
260
|
maven { url 'https://maven.mapsindoors.com/' }
|
|
188
|
-
maven {
|
|
189
|
-
url 'https://api.mapbox.com/downloads/v2/releases/maven'
|
|
190
|
-
authentication {
|
|
191
|
-
basic(BasicAuthentication)
|
|
192
|
-
}
|
|
193
|
-
credentials {
|
|
194
|
-
// Do not change the username below.
|
|
195
|
-
// This should always be `mapbox` (not your username).
|
|
196
|
-
username = "mapbox"
|
|
197
|
-
// Use the secret token you stored in gradle.properties as the password
|
|
198
|
-
password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
|
|
199
|
-
}
|
|
200
|
-
}
|
|
261
|
+
maven { url 'https://api.mapbox.com/downloads/v2/releases/maven' }
|
|
201
262
|
}
|
|
202
263
|
}
|
|
203
264
|
```
|
|
@@ -242,7 +303,6 @@ To enable it, you need to add the configuration in your expo configuration.
|
|
|
242
303
|
"@mapsindoors/react-native-maps-indoors-mapbox/app.plugin.js", // plugin ref
|
|
243
304
|
{
|
|
244
305
|
"publicToken": "PUBLIC_TOKEN", // your map public token
|
|
245
|
-
"downloadToken": "DOWNLOAD_TOKEN", // your download token
|
|
246
306
|
"staticPods": true // OPTIONAL, add if your project uses static linkage for pods (ex: "useFrameworks": "static" with expo-build-properties)
|
|
247
307
|
}
|
|
248
308
|
]
|
package/android/build.gradle
CHANGED
|
@@ -90,23 +90,11 @@ repositories {
|
|
|
90
90
|
|
|
91
91
|
dependencies {
|
|
92
92
|
repositories {
|
|
93
|
-
maven {
|
|
94
|
-
url 'https://api.mapbox.com/downloads/v2/releases/maven'
|
|
95
|
-
authentication {
|
|
96
|
-
basic(BasicAuthentication)
|
|
97
|
-
}
|
|
98
|
-
credentials {
|
|
99
|
-
// Do not change the username below.
|
|
100
|
-
// This should always be `mapbox` (not your username).
|
|
101
|
-
username = "mapbox"
|
|
102
|
-
// Use the secret token you stored in gradle.properties as the password
|
|
103
|
-
password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
|
|
104
|
-
}
|
|
105
|
-
}
|
|
93
|
+
maven { url 'https://api.mapbox.com/downloads/v2/releases/maven' }
|
|
106
94
|
}
|
|
107
95
|
|
|
108
96
|
implementation 'com.mapbox.maps:android-ndk27:11.16.1'
|
|
109
|
-
implementation 'com.mapspeople.mapsindoors:mapbox-ndk27:4.
|
|
97
|
+
implementation 'com.mapspeople.mapsindoors:mapbox-ndk27:4.23.0'
|
|
110
98
|
implementation 'com.facebook.react:react-native:+' // From node_modules
|
|
111
99
|
implementation 'androidx.core:core-ktx:1.3.2'
|
|
112
100
|
implementation 'com.github.bumptech.glide:glide:4.16.0'
|
|
@@ -34,6 +34,10 @@ public class MapboxMapView implements RCMapView {
|
|
|
34
34
|
mContext = context;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
MapView getMapView() {
|
|
38
|
+
return mMapView;
|
|
39
|
+
}
|
|
40
|
+
|
|
37
41
|
@Override
|
|
38
42
|
public void animateCamera(MPCameraUpdate cameraUpdate, Integer duration, OnResultReadyListener onFinished) {
|
|
39
43
|
CameraOptions cameraOptions = toCameraOptions(cameraUpdate);
|
|
@@ -29,6 +29,8 @@ import java.util.Map;
|
|
|
29
29
|
public class MapsIndoorsPackage extends TurboReactPackage implements OnResultReadyListener {
|
|
30
30
|
private volatile MapControlModule mapControlModule;
|
|
31
31
|
private MapsIndoorsViewManager viewManager;
|
|
32
|
+
// The view handed to MapControlModule. UI thread only.
|
|
33
|
+
@Nullable private MapboxMapView mapView;
|
|
32
34
|
private ReactApplicationContext mContext;
|
|
33
35
|
|
|
34
36
|
public MapsIndoorsPackage() {
|
|
@@ -102,13 +104,20 @@ public class MapsIndoorsPackage extends TurboReactPackage implements OnResultRea
|
|
|
102
104
|
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
|
|
103
105
|
mContext = reactContext;
|
|
104
106
|
viewManager = new MapsIndoorsViewManager(reactContext, this);
|
|
107
|
+
viewManager.setOnViewDroppedListener(view -> {
|
|
108
|
+
if (mapControlModule != null && mapView != null && mapView.getMapView() == view) {
|
|
109
|
+
mapControlModule.onViewDropped(mapView);
|
|
110
|
+
mapView = null;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
105
113
|
return Collections.singletonList(viewManager);
|
|
106
114
|
}
|
|
107
115
|
|
|
108
116
|
@Override
|
|
109
117
|
public void onResultReady(@Nullable MIError miError) {
|
|
110
118
|
if (mapControlModule != null && viewManager != null) {
|
|
111
|
-
|
|
119
|
+
mapView = new MapboxMapView(viewManager.getView(), mContext);
|
|
120
|
+
mapControlModule.setView(mapView);
|
|
112
121
|
}
|
|
113
122
|
}
|
|
114
123
|
}
|
|
@@ -52,8 +52,17 @@ public class MapsIndoorsViewManager extends ViewGroupManager<MapView> {
|
|
|
52
52
|
// holds the MapView, so a weak key would be kept reachable by its own value and never clear.
|
|
53
53
|
private final Map<MapView, MapViewLifecycleOwner> lifecycleOwners = new HashMap<>();
|
|
54
54
|
|
|
55
|
+
// setupLayout's frame callback re-posts itself every frame, so the Choreographer would keep it, and
|
|
56
|
+
// the view it lays out, alive for good. Tracked per view so onDropViewInstance can stop it (SPEX-2885).
|
|
57
|
+
private final Map<View, Choreographer.FrameCallback> layoutCallbacks = new HashMap<>();
|
|
58
|
+
|
|
59
|
+
interface OnViewDroppedListener {
|
|
60
|
+
void onViewDropped(MapView view);
|
|
61
|
+
}
|
|
62
|
+
|
|
55
63
|
ReactApplicationContext mReactContext;
|
|
56
64
|
OnResultReadyListener mOnMapReadyCallback;
|
|
65
|
+
@Nullable OnViewDroppedListener mOnViewDroppedListener;
|
|
57
66
|
|
|
58
67
|
public MapsIndoorsViewManager(ReactApplicationContext reactContext, OnResultReadyListener onMapReadyCallback) {
|
|
59
68
|
mReactContext = reactContext;
|
|
@@ -82,6 +91,10 @@ public class MapsIndoorsViewManager extends ViewGroupManager<MapView> {
|
|
|
82
91
|
});
|
|
83
92
|
}
|
|
84
93
|
|
|
94
|
+
void setOnViewDroppedListener(@Nullable OnViewDroppedListener listener) {
|
|
95
|
+
mOnViewDroppedListener = listener;
|
|
96
|
+
}
|
|
97
|
+
|
|
85
98
|
private void setHostResumedOnAll(boolean hostResumed) {
|
|
86
99
|
for (MapViewLifecycleOwner owner : lifecycleOwners.values()) {
|
|
87
100
|
owner.setHostResumed(hostResumed);
|
|
@@ -138,6 +151,14 @@ public class MapsIndoorsViewManager extends ViewGroupManager<MapView> {
|
|
|
138
151
|
@Override
|
|
139
152
|
public void onDropViewInstance(@NonNull MapView view) {
|
|
140
153
|
super.onDropViewInstance(view);
|
|
154
|
+
Choreographer.FrameCallback layoutCallback = layoutCallbacks.remove(view);
|
|
155
|
+
if (layoutCallback != null) {
|
|
156
|
+
Choreographer.getInstance().removeFrameCallback(layoutCallback);
|
|
157
|
+
}
|
|
158
|
+
// Before the map is destroyed, so its MapControl can still tear down against it.
|
|
159
|
+
if (mOnViewDroppedListener != null) {
|
|
160
|
+
mOnViewDroppedListener.onViewDropped(view);
|
|
161
|
+
}
|
|
141
162
|
MapViewLifecycleOwner lifecycleOwner = lifecycleOwners.remove(view);
|
|
142
163
|
if (lifecycleOwner != null) {
|
|
143
164
|
// Driving the lifecycle to DESTROYED lets the MapView's lifecycle observer tear it down on
|
|
@@ -287,14 +308,19 @@ public class MapsIndoorsViewManager extends ViewGroupManager<MapView> {
|
|
|
287
308
|
}
|
|
288
309
|
|
|
289
310
|
public void setupLayout(View view) {
|
|
290
|
-
Choreographer.
|
|
311
|
+
Choreographer.FrameCallback layoutCallback = new Choreographer.FrameCallback() {
|
|
291
312
|
@Override
|
|
292
313
|
public void doFrame(long frameTimeNanos) {
|
|
293
314
|
manuallyLayoutChildren(view);
|
|
294
315
|
view.getViewTreeObserver().dispatchOnGlobalLayout();
|
|
295
316
|
Choreographer.getInstance().postFrameCallback(this);
|
|
296
317
|
}
|
|
297
|
-
}
|
|
318
|
+
};
|
|
319
|
+
Choreographer.FrameCallback previous = layoutCallbacks.put(view, layoutCallback);
|
|
320
|
+
if (previous != null) {
|
|
321
|
+
Choreographer.getInstance().removeFrameCallback(previous);
|
|
322
|
+
}
|
|
323
|
+
Choreographer.getInstance().postFrameCallback(layoutCallback);
|
|
298
324
|
}
|
|
299
325
|
|
|
300
326
|
/**
|
|
@@ -66,6 +66,11 @@ public class DirectionsRendererModule extends ReactContextBaseJavaModule impleme
|
|
|
66
66
|
public DirectionsRendererModule(@NonNull ReactApplicationContext reactContext, MapControlModule mapControl) {
|
|
67
67
|
super(reactContext);
|
|
68
68
|
mapControl.setOnMapControlReadyListener(this);
|
|
69
|
+
// The renderer holds the MapControl, so it goes with it.
|
|
70
|
+
mapControl.setOnMapControlDestroyedListener(() -> {
|
|
71
|
+
mMapControl = null;
|
|
72
|
+
mRenderer = null;
|
|
73
|
+
});
|
|
69
74
|
mCtx = reactContext;
|
|
70
75
|
}
|
|
71
76
|
|
|
@@ -288,10 +293,13 @@ public class DirectionsRendererModule extends ReactContextBaseJavaModule impleme
|
|
|
288
293
|
}
|
|
289
294
|
|
|
290
295
|
@ReactMethod
|
|
291
|
-
public void setRoute(String routeString, String icons, int legIndex, final Promise promise) {
|
|
296
|
+
public void setRoute(String routeString, String icons, int legIndex, @Nullable String routeId, final Promise promise) {
|
|
292
297
|
if (mRenderer != null) {
|
|
293
298
|
Context ctx = mCtx.getApplicationContext();
|
|
294
|
-
|
|
299
|
+
// The route getRoute kept, when JavaScript names one: only that instance carries the
|
|
300
|
+
// endpoints the directions Insights events report.
|
|
301
|
+
MPRoute kept = RouteStore.get(routeId);
|
|
302
|
+
MPRoute route = kept != null ? kept : gson.fromJson(routeString, MPRoute.class);
|
|
295
303
|
if (icons != null) {
|
|
296
304
|
new Handler().post(()-> {
|
|
297
305
|
// Posted to the main looper, so this body is off React Native's stack: a throw
|
|
@@ -108,6 +108,7 @@ public class DirectionsServiceModule extends ReactContextBaseJavaModule {
|
|
|
108
108
|
try {
|
|
109
109
|
if (route != null) {
|
|
110
110
|
map.putString("route", gson.toJson(route));
|
|
111
|
+
map.putString("routeId", RouteStore.keep(route));
|
|
111
112
|
}
|
|
112
113
|
if (error != null) {
|
|
113
114
|
map.putString("error", gson.toJson(error));
|