rowanwins / maplibregl-mapbox-request-transformer

Transform mapbox:// urls in MapboxGL Styles for use in MapLibreGL.
MIT License
26 stars 5 forks source link

Error on usage #8

Open pafech opened 1 year ago

pafech commented 1 year ago

I receive this error while drawing the map:

Error: layers[35].filter[3][1][0]: Unknown expression "pitch". If you wanted a literal array, use ["literal", [...]].

The first part changes, but it's always highlighting the 'Unknown expression "pitch"'.

dbauszus-glx commented 9 months ago

I am hitting the same error with a new mapbox style parsed through the request transformer.

dbauszus-glx commented 9 months ago

This issue is not related to the request transformer. I assume an update attempt was made on the mapbox style. Mapbox Studio styles must support MapboxGL 1.1. If you auto update you will change the projection to globe [from mercator] and introduce the pitch filter which will break compatibility with maplibre. image

rowanwins commented 9 months ago

Thanks for investigating @dbauszus-glx

If there is a particular map style someone can point me to I can investigate further.

dbauszus-glx commented 9 months ago

@rowanwins Any new style from the classic templates will fail.

image

If you open the streets v8 template you will notice the default projection being globe and support for mapboxgl v3.1.0+

image

Dropping the supported version down to v1.1.0 for compatibility with maplibre and you will see the warnings related to the warning from the maplibre library.

image

I hope the country layer JSON where you can see the ["pitch"] array which causes the maplibre library to fail.

[
  {
    "minzoom": 1,
    "layout": {
      "icon-image": "",
      "text-field": [
        "coalesce",
        [
          "get",
          "name_en"
        ],
        [
          "get",
          "name"
        ]
      ],
      "text-line-height": 1.1,
      "text-max-width": 6,
      "text-font": [
        "DIN Pro Medium",
        "Arial Unicode MS Regular"
      ],
      "text-radial-offset": [
        "step",
        [
          "zoom"
        ],
        0.6,
        8,
        0
      ],
      "text-justify": [
        "step",
        [
          "zoom"
        ],
        [
          "match",
          [
            "get",
            "text_anchor"
          ],
          [
            "left",
            "bottom-left",
            "top-left"
          ],
          "left",
          [
            "right",
            "bottom-right",
            "top-right"
          ],
          "right",
          "center"
        ],
        7,
        "auto"
      ],
      "text-size": [
        "interpolate",
        [
          "cubic-bezier",
          0.2,
          0,
          0.7,
          1
        ],
        [
          "zoom"
        ],
        1,
        [
          "step",
          [
            "get",
            "symbolrank"
          ],
          11,
          4,
          9,
          5,
          8
        ],
        9,
        [
          "step",
          [
            "get",
            "symbolrank"
          ],
          22,
          4,
          19,
          5,
          17
        ]
      ]
    },
    "maxzoom": 10,
    "filter": [
      "all",
      [
        "match",
        [
          "get",
          "class"
        ],
        [
          "country",
          "disputed_country"
        ],
        [
          "match",
          [
            "get",
            "worldview"
          ],
          [
            "all",
            "US"
          ],
          true,
          false
        ],
        false
      ],
      [
        "step",
        [
          "pitch"
        ],
        true,
        50,
        [
          "<",
          [
            "distance-from-center"
          ],
          3
        ],
        60,
        [
          "<",
          [
            "distance-from-center"
          ],
          4
        ],
        70,
        [
          "<",
          [
            "distance-from-center"
          ],
          5
        ]
      ]
    ],
    "type": "symbol",
    "source": "composite",
    "id": "country-label",
    "paint": {
      "icon-opacity": [
        "step",
        [
          "zoom"
        ],
        [
          "case",
          [
            "has",
            "text_anchor"
          ],
          1,
          0
        ],
        7,
        0
      ],
      "text-color": "hsl(220, 30%, 0%)",
      "text-halo-color": [
        "interpolate",
        [
          "linear"
        ],
        [
          "zoom"
        ],
        2,
        "hsla(20, 25%, 100%, 0.75)",
        3,
        "hsl(20, 25%, 100%)"
      ],
      "text-halo-width": 1.25
    },
    "source-layer": "place_label"
  }
]