maplibre / flutter-maplibre-gl

Customizable, performant and vendor-free vector and raster maps, flutter wrapper for maplibre-native and maplibre-gl-js (fork of flutter-mapbox-gl/maps)
https://pub.dev/packages/maplibre_gl
Other
223 stars 120 forks source link

LineLayerProperties lineDasharray not working #148

Open JanikoNaber opened 2 years ago

JanikoNaber commented 2 years ago

Hi all, I'm trying to add two lines with a line-dasharray property as a new source.

_mapController.addSource(
      "off-piste-section",
      GeojsonSourceProperties(
        data:
          {  "type": "FeatureCollection",
          "crs": { "type": "name", "properties": { "name": "off-piste-section" } },
          "features": [
          { "type": "Feature", "properties": { "id": "off-piste-section-line1"},  
            "geometry": { "type": "LineString", 
            "coordinates": [ [-151.2484, 61.2705, 0 ], [0, 0, 0 ]] } },
          { "type": "Feature", "properties": { "id": "off-piste-section-line2" }, 
            "geometry": { "type": "LineString", 
            "coordinates": [ [180.2484, 60.2705, 0 ], [0, 0, 0 ]], } },        
          ]
        },
      )
    ).then((value) {
      _mapController.addLayer(
        "off-piste-section",
        "off-piste-section-line",
        LineLayerProperties(
          lineWidth: 6,
          lineColor: "#de0202",
          lineOpacity: 0.9,
          lineCap: "round",
          lineJoin: "round",  
          lineDasharray: [5, 2]
        ));
    });

Adding the source works fine and also all other attributes are working. Except the lineDasharry attribute. The following error is given by the console: Error setting property: line-dasharray value must be an array of numbers

Adding the same layer in the style.json, works fine.

    {
      "id": "off-piste-section-line",
      "type": "line",
      "source": "off-piste-section",
      "paint": {
        "line-dasharray": [5, 2],
        "line-width": 6,
        "line-opacity": 0.9,
        "line-color": "rgba(222, 2, 2, 1)"
      }
    }

Looks like an error in the flutter binding. Maybe just a small issue.

Nonnis-M commented 1 year ago

I faced the same error... any news?

m0nac0 commented 1 year ago

On what platforms do you see this issue?

gabbopalma commented 3 months ago

Hi, you can see the "fix" for this on this issue. Just use expression instead of a List.