mapbox / mapbox/mapbox-maps-flutter
I'm trying to add an image (Uint8List) to the maps style, but i get a error: Throwable, java.lang.Throwable: mismatched image size, Cause: null, Stacktrace: java.lang.Throwable: mismatched image size
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Dart
- Sterne
- 380
- Forks
- 204
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
I'm trying to add an image (Uint8List) to the maps style, so that I can reference it later in a feature when I assemble a source geojson. This is what I tried:
Andriod 13.0.
ByteData byteData =
await rootBundle.load('assets/map_icons/home.png');
Uint8List image = byteData.buffer.asUint8List();
// So far everything is okay, the list is correct.
// But here I struggle with understanding what half of the properties do. The next line throws an error.
await mapController.style.addStyleImage(
assetName, // A string (which I later use to reference the image in a geojson source)
1,
MbxImage(width: 50, height: 50, data: image),
false,
[],
[],
null,
);
The error thrown is:
PlatformException (PlatformException(Throwable, java.lang.Throwable: mismatched image size, Cause: null, Stacktrace: java.lang.Throwable: mismatched image size
at com.mapbox.maps.mapbox_maps.StyleController.addStyleImage$lambda-49(StyleController.kt:641)
at com.mapbox.maps.mapbox_maps.StyleController.$r8$lambda$9qzAKUZTMYPcXQ8_jKe8hkSxnyU(Unknown Source:0)
at com.mapbox.maps.mapbox_maps.StyleController$$ExternalSyntheticLambda0.onStyleLoaded(Unknown Source:17)
at com.mapbox.maps.MapboxMap.getStyle(MapboxMap.kt:355)
at com.mapbox.maps.mapbox_maps.StyleController.addStyleImage(StyleController.kt:610)
at com.mapbox.maps.mapbox_maps.StyleController.addStyleImage(StyleController.kt:17)
at com.mapbox.maps.pigeons.FLTMapInterfaces$StyleManager$-CC.lambda$setup$34(FLTMapInterfaces.java:7898)
at com.mapbox.maps.pigeons.FLTMapInterfaces$StyleManager$$ExternalSyntheticLambda20.onMessage(Unknown Source:2)
at io.flutter.plugin.common.BasicMessageChannel$IncomingMessageHandler.onMessage(BasicMessageChannel.java:217)
at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:250)
at android.app.ActivityThread.main(ActivityThread.java:7806)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)
, null))
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Der Bericht nennt den Flutter-Aufruf addStyleImage und den Android-Stack-Trace-Eintrag StyleController.kt, aber keine Repository-Datei und keinen Test. Beginne mit der Prüfung der Dokumentation zu MbxImage und addStyleImage sowie der Bildabmessungen, die durch die PNG-Bytes dargestellt werden. Die Aufgabe ist erledigt, wenn das Bild ohne die Ausnahme wegen nicht übereinstimmender Bildgröße registriert wird und aus der GeoJSON-Quelle referenziert werden kann.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- android, dart, flutter
- Bereich
- mobile-dev
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 35/100