mapbox / mapbox-maps-flutter

Interactive, thoroughly customizable maps for Flutter powered by Mapbox Maps SDK
https://www.mapbox.com/mobile-maps-sdk
Other
288 stars 119 forks source link

★★★★ Please fix SymbolLayer ★★★★ #343

Open zsx29 opened 10 months ago

zsx29 commented 10 months ago

"TextField" does not exist. Please fix it quickly

evil159 commented 9 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.

dhaq commented 8 months ago

I want to set my "text-field" is a number, but it can't show. Only show String. Please help

evil159 commented 7 months ago

@dhaq You can convert number to a string before passing it to the map.

timeuser commented 7 months ago

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))
noforeignland commented 7 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.

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?

maios commented 6 months ago

Hi all, could you please provide which MapboxMaps Flutter plugin version you are using?

Pavlo-Freebee commented 6 months ago

Hi all, could you please provide which MapboxMaps Flutter plugin version you are using?

Issue still present on latest version (1.1.0)

Pavlo-Freebee commented 6 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.

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

noforeignland commented 3 months ago

Should this ticked be closed now? It looks like text can be added in 2.0.x. Thanks.