@mapsindoors/react-native-maps-indoors-mapbox 2.9.1 → 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 CHANGED
@@ -2,11 +2,52 @@
2
2
 
3
3
  ## Documentation
4
4
 
5
- Visit [our reference document site](https://app.mapsindoors.com/mapsindoors/reference/react-native/mapbox/2.9.1/index.html) to get an overview of what the MapsIndoors SDK offers.
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.1] - 2026-10-15
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
10
51
 
11
52
  #### Changed
12
53
 
@@ -179,8 +220,7 @@ end
179
220
 
180
221
  #### Providing API key
181
222
 
182
- 1. Navigate to your application settings and add your Mapbox public access token to info with the key `MBXAccessToken`
183
- 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`
184
224
 
185
225
  ### Android
186
226
 
@@ -208,9 +248,8 @@ To get the underlying Mapbox to function, you need to perform the following step
208
248
  ​
209
249
  The plugin Gradle project has trouble resolving the MapsIndoors dependency, so to ensure that it is resolved correctly, do the following:
210
250
 
211
- 1. Navigate to the app `gradle.properties` and add the value MAPBOX_DOWNLOADS_TOKEN with your Mapbox download access token.
212
- 2. Navigate to the app's project level `build.gradle`.
213
- 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
214
253
  ​
215
254
 
216
255
  ```groovy
@@ -219,19 +258,7 @@ allprojects {
219
258
  google()
220
259
  mavenCentral()
221
260
  maven { url 'https://maven.mapsindoors.com/' }
222
- maven {
223
- url 'https://api.mapbox.com/downloads/v2/releases/maven'
224
- authentication {
225
- basic(BasicAuthentication)
226
- }
227
- credentials {
228
- // Do not change the username below.
229
- // This should always be `mapbox` (not your username).
230
- username = "mapbox"
231
- // Use the secret token you stored in gradle.properties as the password
232
- password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
233
- }
234
- }
261
+ maven { url 'https://api.mapbox.com/downloads/v2/releases/maven' }
235
262
  }
236
263
  }
237
264
  ```
@@ -276,7 +303,6 @@ To enable it, you need to add the configuration in your expo configuration.
276
303
  "@mapsindoors/react-native-maps-indoors-mapbox/app.plugin.js", // plugin ref
277
304
  {
278
305
  "publicToken": "PUBLIC_TOKEN", // your map public token
279
- "downloadToken": "DOWNLOAD_TOKEN", // your download token
280
306
  "staticPods": true // OPTIONAL, add if your project uses static linkage for pods (ex: "useFrameworks": "static" with expo-build-properties)
281
307
  }
282
308
  ]
@@ -90,19 +90,7 @@ 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'
@@ -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
- mapControlModule.setView(new MapboxMapView(viewManager.getView(), mContext));
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.getInstance().postFrameCallback(new Choreographer.FrameCallback() {
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
- MPRoute route = gson.fromJson(routeString, MPRoute.class);
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));