Closed andokai closed 1 year ago
Hi @andokai. In the example provided you aren't ever loading any of the JSON styles (you are just defining a "style" for the ZXY map tiles; then manually adding the source/layers for the boundaries) - so the glyphs URL isn't getting set.
If you add the glyphs to your style definition as follows:
const style = {
version: 8,
glyphs: 'https://api.os.uk/maps/vector/v1/vts/resources/fonts/{fontstack}/{range}.pbf?key=' + apiKey,
sources: {
'raster-tiles': {
type: 'raster',
tiles: [
'https://api.os.uk/maps/raster/v1/zxy/Outdoor_3857/{z}/{x}/{y}.png?key=' + apiKey,
],
tileSize: 256,
},
},
layers: [
{
id: 'os-maps-zxy',
type: 'raster',
source: 'raster-tiles',
},
],
};
... and add a 'text-font': ['Source Sans Pro Regular']
to your boundary-symbols layer layout property (plus the filter: 'filter': ['in', 'AREA_CODE', 'CTY', 'GLA']
) - then you should see the boundary labels as expected.
If you were to implement the latest version of MapLibre GL JS library (v3.0.1) - you could also investigate the map.setGlyphs() function...
Hi, @tmnnrs, sorry, the example was put together hastily. I'll see if I can put together a more representative one.
If I manually construct the style object, I expect it will work, however what doesn't work is pointing to one of the json files in this repository.
Most of the styles in the repo will still reference the sprites and glyphs from the default (api.os.uk) stylesheet. All of the resources referenced in in the default style require authentication. You can use the transformRequest()
callback to resolve this (see http://localhost/public/os-data-hub-examples/os-vector-tile-api/vts-example-custom-style#maplibre-gl-js).
Yeah, I'm aware of the need for the request transformation, I wouldn't have any map tiles otherwise.
Here's a more complete example https://codesandbox.io/s/cool-waterfall-c3xr92?file=/src/index.js
Adding "text-font": ["Source Sans Pro Regular"]
to the layout property for clusterCountLayer seemed to work for me.
https://maplibre.org/maplibre-style-spec/layers/#layout-symbol-text-font defaults to ["Open Sans Regular","Arial Unicode MS Regular"] which we [OS] don't use...
Ok, that fixes it, thanks! Are the fonts available listed somewhere?
The default style for the basemap has the following fonts available:
The overlays (Boundaries, Greenspace, etc) simply have Tahoma Regular available.
Awesome, thanks @tmnnrs!
Hi,
I'm trying to add labels to markers and polygons but I'm running into errors due to the style allegedly missing a "glyphs" property. I can however see that the styles all do appear to have a "glyphs" property so I'm not sure what's going on. I've modified one of the existing examples to demonstrate the issue.