Open zsx29 opened 10 months ago
Hi @zsx29, thank you for reporting this, we've taken this into our immediate working plan, meanwhile you can use:
mapboxMap.style.setStyleLayerProperty("layer-id", "text-field", "My text");
to set the value of this property after you have added layer with "layer-id" to the style.
I want to set my "text-field" is a number, but it can't show. Only show String. Please help
@dhaq You can convert number to a string before passing it to the map.
This is happening to me also. It's only a problem on Android. iOS works fine.
This fails to set the text field: mapboxMap.style.setStyleLayerProperty("layer-id", "text-field", "210");
This works: mapboxMap.style.setStyleLayerProperty("layer-id", "text-field", "_210");
Anything where the string passed in is numerals only fails. Very odd.
When it fails I get this exception:
Exception has occurred.
PlatformException (PlatformException(java.lang.Throwable: Formatted must be plain string or array type., Throwable, Cause: null, Stacktrace: java.lang.Throwable: Formatted must be plain string or array type.
at com.mapbox.maps.mapbox_maps.StyleController.setStyleLayerProperty$lambda$18(StyleController.kt:213)
at com.mapbox.maps.mapbox_maps.StyleController.$r8$lambda$MpWjrmV9gatZ-HjWrSMdbJIAO9c(Unknown Source:0)
at com.mapbox.maps.mapbox_maps.StyleController$$ExternalSyntheticLambda13.onStyleLoaded(Unknown Source:8)
at com.mapbox.maps.MapboxMap.getStyle(MapboxMap.kt:359)
at com.mapbox.maps.mapbox_maps.StyleController.setStyleLayerProperty(StyleController.kt:209)
at com.mapbox.maps.pigeons.FLTMapInterfaces$StyleManager$-CC.lambda$setup$15(FLTMapInterfaces.java:8990)
at com.mapbox.maps.pigeons.FLTMapInterfaces$StyleManager$$ExternalSyntheticLambda39.onMessage(Unknown Source:2)
at io.flutter.plugin.common.BasicMessageChannel$IncomingMessageHandler.onMessage(BasicMessageChannel.java:261)
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:322)
at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8177)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
, null))
Hi @zsx29, thank you for reporting this, we've taken this into our immediate working plan, meanwhile you can use:
mapboxMap.style.setStyleLayerProperty("layer-id", "text-field", "My text");
to set the value of this property after you have added layer with "layer-id" to the style.
This only works if all your markers in the layer have the same text right? When are we likely to see expressions made available here so that we can add meaningful labels?
Hi all, could you please provide which MapboxMaps Flutter plugin version you are using?
Hi all, could you please provide which MapboxMaps Flutter plugin version you are using?
Issue still present on latest version (1.1.0)
Hi @zsx29, thank you for reporting this, we've taken this into our immediate working plan, meanwhile you can use:
mapboxMap.style.setStyleLayerProperty("layer-id", "text-field", "My text");
to set the value of this property after you have added layer with "layer-id" to the style.
Good temporary workaround!
Just wanted to add that if you're setting the text through a Feature property (i.e. properties: {'title': 'text goes here'}) then we need to set the value the same way we do in the react library: mapboxMap.style.setStyleLayerProperty("layer-id", "text-field", ['get', 'title']);
. @noforeignland
Should this ticked be closed now? It looks like text can be added in 2.0.x. Thanks.
"TextField" does not exist. Please fix it quickly