Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] linePattern on lineLayer not rendering #504

Open
nijs9 opened this issue Sep 18, 2024 · 2 comments
Open

[BUG] linePattern on lineLayer not rendering #504

nijs9 opened this issue Sep 18, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@nijs9
Copy link

nijs9 commented Sep 18, 2024

Platforms

android

Version of flutter maplibre_gl

0.20

Bug Description

I'm trying to apply a linePattern to a LineLayer because a lineDasharray doesn't seem to work.

On iOS, the linePattern is rendering OK. On Android I only see a white line without pattern. I can see this in the logs: [JNI]: Error setting property: line-pattern expected a literal expression

Steps to Reproduce

  1. Add a lineLayer
  2. Add a linePattern
  3. Run on Android

Expected Results

See the linePattern on the map.

Actual Results

linePattern not rendering on Android. On iOS no problem.

Code Sample

custom-tracks is a vector source:

Future<void> _addCustomTracksUnpavedLayer() async {
    await mapController.addLineLayer(
      'custom-tracks',
      'custom-tracks-unpaved',
      LineLayerProperties(
        lineColor: RPColors.colorUnpaved,
        lineWidth: const [
          Expressions.interpolate,
          ["linear"],
          [Expressions.zoom],
          10,
          1.2,
          15,
          1.8
        ],
        linePattern: 'unpaved-pattern',
      ),
      belowLayerId: isDarkMode ? darkModeBelowLayerId : lightModeBelowLayerId,
      sourceLayer: 'tracks_data_$flavor',
      minzoom: 7,
      filter: [
        'all',
        ['==', 'terrain', 'unpaved'],
        ['!=', 'onlylf', 1]
      ],
    );
  }

unpaved-pattern is added to the map in this way:

addImageFromAsset(
          'unpaved-pattern', 'assets/mapicons/unpaved-pattern.png')

Future<void> addImageFromAsset(String name, String assetName) async {
    final bytes = await rootBundle.load(assetName);
    final list = bytes.buffer.asUint8List();
    return mapController.addImage(name, list);
  }
@nijs9 nijs9 added the bug Something isn't working label Sep 18, 2024
@nijs9 nijs9 changed the title [BUG] <title> [BUG] linePattern on lineLayer not rendering Sep 18, 2024
@mikefaust-jm
Copy link

I just had the same problem. The fix was to put the asset name inside this expression:

linePattern: [Expressions.image, 'unpaved-pattern']

@nijs9
Copy link
Author

nijs9 commented Sep 19, 2024

@mikefaust-jm Thank you for sharing! This fixed the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants