Giter VIP home page Giter VIP logo

Comments (4)

LjubiTech-Maxko avatar LjubiTech-Maxko commented on May 16, 2024 1

You can first add the layer with default properties and then use
mapboxMap.style.setStyleLayerProperty('layer_id', 'color', jsonEncode(['get','custom-color']))

from mapbox-maps-flutter.

dawid-niedzwiecki avatar dawid-niedzwiecki commented on May 16, 2024

You can first add the layer with default properties and then use mapboxMap.style.setStyleLayerProperty('layer_id', 'color', jsonEncode(['get','custom-color']))

Hey, I just tried that and I get this error:

PlatformException (PlatformException(Throwable, java.lang.Throwable: layer doesn't support this property, Cause: null, Stacktrace: java.lang.Throwable: layer doesn't support this property
	at com.mapbox.maps.mapbox_maps.StyleController.setStyleLayerProperty$lambda-18(StyleController.kt:212)
	at com.mapbox.maps.mapbox_maps.StyleController.$r8$lambda$WKv9Hkp6n6Ramjn-IsD3ANd83Co(Unknown Source:0)
	at com.mapbox.maps.mapbox_maps.StyleController$$ExternalSyntheticLambda35.onStyleLoaded(Unknown Source:8)
	at com.mapbox.maps.MapboxMap.getStyle(MapboxMap.kt:355)
	at com.mapbox.maps.mapbox_maps.StyleController.setStyleLayerProperty(StyleController.kt:208)
	at com.mapbox.maps.pigeons.FLTMapInterfaces$StyleManager$-CC.lambda$setup$15(FLTMapInterfaces.java:7200)
	at com.mapbox.maps.pigeons.FLTMapInterfaces$StyleManager$$ExternalSyntheticLambda40.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))

This is how I create the layer:

await mapController.style.addSource(GeoJsonSource(id: 'styleSource', data: json.encode(geojson))); // Here geojson is a Map<String, dynamic>
await mapController.style.addLayer(
  LineLayer(
    id: 'styleLayer',
    sourceId: 'styleSource',
    lineCap: LineCap.ROUND,
    lineWidth: 3,
  ),
);
await mapController.style.setStyleLayerProperty(
  'styleLayer',
  'color',
  json.encode(['get', 'line-color']),
);

from mapbox-maps-flutter.

LjubiTech-Maxko avatar LjubiTech-Maxko commented on May 16, 2024

Line layer does not have 'color' property, it is 'line-color'.

Check out this: https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#line

from mapbox-maps-flutter.

dawid-niedzwiecki avatar dawid-niedzwiecki commented on May 16, 2024

Oh, okay, that's where the names come from :D Thanks!

from mapbox-maps-flutter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.