mapbox / mapbox/mapbox-maps-flutter
Source name is not in style
Nobody has claimed this yet.
- Dominant language
- Dart
- Stars
- 380
- Forks
- 204
- PR merge metrics
- No merged PRs in 30d
Description
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!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the getSource and addSource sequence in the Flutter implementation against StyleController.kt:40 and map_interfaces.dart:6541. Reproduce the Android failure with mapbox_maps_flutter 2.6.0 and determine when the source is absent from the style. Done means the source update or creation path no longer produces “Source bikes is not in style” and is covered by a relevant test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100