tileserver-gl
tileserver-gl copied to clipboard
Unknown expression "slice"
I tried to style some layer with "slice" expression but it's not working
Can you update mapbox-gl-js to 1.10.0 or more? Currently tileserver is using mapbox-gl-js version 1.6.1 and that doesn't contain expression "slice"
Is this issue still relevant since the last update to v4?
Guessing it should be resolved by the maplibre-gl-js 2.4.0 used now, since that was forked from mapbox-gl-js 1.14 I think.
I also have this problem, maybe the update didn't resolve the issue. I will look at maplibre and see if the problem is fixed yet
I am using Maputnik to create/edit my style, and the expression is working fine there
Does anyone have any example style we could test with?
According to the maplibre style-spec docs, it should be supported https://maplibre.org/maplibre-style-spec/expressions/#slice
The style I am working on is not mine so I am hesitant to share the entire style, but the part I am working on is the text field.
In Maputnik the following layer works:
{
"filter": [
"all",
["==", "class", "country"],
["==", "rank", 2],
["has", "iso_a2"]
],
"id": "place-country-2",
"layout": {
"text-field": [
"coalesce",
[
"get",
[
"concat",
"name:",
[
"slice",
[
"resolved-locale",
["collator", {}]
],
0,
2
]
]
],
["get", "name:int"],
[
"concat",
["get", "name:latin"],
["literal", "\n"],
["get", "name:nonlatin"]
]
],
"text-font": ["Noto Sans Bold"],
"text-max-width": 6.25,
"text-padding": 0,
"text-size": {
"stops": [[1, 11], [4, 15]]
},
"text-transform": "none",
"visibility": "visible"
},
"maxzoom": 7,
"metadata": {
"mapbox:group": "1444849242106.713"
},
"paint": {
"text-color": {
"stops": [
[4, "rgba(83, 83, 100, 1)"],
[7, "rgba(200, 200, 200, 1)"]
]
},
"text-halo-blur": 1,
"text-halo-color": "rgba(255,255,255,0.8)",
"text-halo-width": 2
},
"source": "openmaptiles",
"source-layer": "place",
"type": "symbol"
}
When I start tileserver I get the following error
mlgl: {
class: 'ParseStyle',
severity: 'WARNING',
text: '[1][1][2][0]: Unknown expression "slice". If you wanted a literal array, use ["literal", [...]].'
}
I am using the latest Docker image to run Tileserver
It seems actually that the error messages aren't really a problem. I have checked again after restarting and the style is showing in the browser now with the new labels, despite the warnings in the terminal.
The warning messages are misleading but actually the problem appears to be resolved.
Thanks for looking at this
I just realized that error is a Maplibre-Native error. It looks like 'slice' is not yet implemented in Maplibre Native https://github.com/maplibre/maplibre-native/issues/264
That means this will probably look ok in the 'View' and 'Vector', which don't do any rendering and just use Maplibre-gl-js. The rendered views like 'Raster' view and WMTS, which use maplibre-native may be missing support for this feature at this time.
Thanks for the explanation, good to know
Just an FYI, Maplibre Native 5.3.1 now includes 'slice' and 'index-of' expressions. this is included in TileServer-GL 4.10.0