mapbox-maps-flutter
mapbox-maps-flutter copied to clipboard
Source name is not in style
I see these cases since several previous versions, I want to know if we are using the implementation correctly, in case this is correct, how can we solve this exception?
This error does not allow to render on the map (in this case pins, but also polygons).
Full log native:
data:text/text;charset=utf-8,
PlatformException(Throwable, java.lang.Throwable: Source bikes is not in style, Cause: null, Stacktrace: java.lang.Throwable: Source bikes is not in style
at com.mapbox.maps.mapbox_maps.StyleController.setStyleSourceProperties(StyleController.kt:40)
at com.mapbox.maps.mapbox_maps.pigeons.StyleManager$Companion.setUp$lambda$59$lambda$58(MapInterfaces.kt:40)
at com.mapbox.maps.mapbox_maps.pigeons.StyleManager$Companion.a0(MapInterfaces.kt:1)
at com.mapbox.maps.mapbox_maps.pigeons.o.e(R8$$SyntheticClass:20)
at zi.b$a.a(BasicMessageChannel.java:16)
at oi.b.run(R8$$SyntheticClass:128)
at android.os.Handler.handleCallback(Handler.java:991)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loopOnce(Looper.java:232)
at android.os.Looper.loop(Looper.java:317)
at android.app.ActivityThread.main(ActivityThread.java:8787)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:591)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:871)
, null)
When the exception was thrown, this was the stack:
0 StyleManager.setStyleSourceProperties (/home/builder/.pub-cache/hosted/pub.dev/mapbox_maps_flutter-2.6.0/lib/src/pigeons/map_interfaces.dart:6541:7)
Flutter Implementation
try {
final existingSource = await state.controller?.style
.getSource(id)
.catchError((_) => null) as GeoJsonSource?;
if (existingSource != null) {
await existingSource.updateGeoJSON(data);
return existingSource;
} else {
final source = GeoJsonSource(
id: id,
data: data,
cluster: cluster,
clusterMinPoints: clusterMinPoints,
clusterMaxZoom: clusterMaxZoom,
clusterRadius: clusterRadius,
);
await state.controller?.style.addSource(source);
return source;
}
} catch (e) {
debugPrint('MapsCubit Error _addOrUpdateSource layer $id: $e');
return null;
}
Flutter version
- 3.27.2
Mapbox version
- mapbox_maps_flutter: ^2.6.0
This happens mostly on android devices
- Samsung Galaxy A53 5G
- Samsung Galaxy S22 Ultra
- Google Pixel 5
- Google Pixel 8
- Huawei P30 Pro
- Motorola moto g32
- Nothing A063
Thanks!
I am seeing the same exception. After some debugging my guess is that there are some async issues with the Mapbox implementation where the state is not always up to date when validating.