-
I have a issues when initializing the map, setting the localIdeographFontFamily: "sans serif", layer type: "symbol", correctly displaying "text field" in Chinese, and not displaying annotations when "text field" is in English. const map = new maplibregl.Map({
container: "container",
style: {
version: 8,
name: "defaultMap",
metadata: {},
bearing: 0,
pitch: 0,
transition: {
duration: 300,
delay: 0,
},
sources: {},
glyphs: "./online-fonts/{fontstack}/{range}.pbf", // When style glyphs cannot be accessed or 404
layers: [],
},
pitch: 0,
preserveDrawingBuffer: true,
localIdeographFontFamily: "sans-serif",
});
mapInstance.addSource("sourceId", {
type: "geojson",
data: data, // any data
});
map.on('load', () => {
map.addLayer({
id: "layerId",
type: "symbol",
source: "sourceId",
layout: {
"visibility": "visible",
"text-allow-overlap": true,
"icon-allow-overlap": true,
"icon-ignore-placement": true,
"text-max-width": 10,
// English or Number not visible
// "text-field": "value",
// Chinese can be visible
"text-field": "上海",
"text-font": ["sans-serif"],
"text-size": 16,
"text-line-height": 1,
"text-padding": 0,
"icon-size": 0,
},
paint: {
"text-opacity": 1,
"text-color": "#000000",
"text-halo-color": "#FFFFFF",
"text-halo-width": 1,
"text-halo-blur": 0,
},
});
}) |
Beta Was this translation helpful? Give feedback.
Answered by
HarelM
Feb 22, 2024
Replies: 1 comment 3 replies
-
I'm not 100% sure but I believe the Chinese font is taken from the browser while the English is taken from the glyph URL. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's a performance consideration, using the glyphs is much faster than using the browser fonts.
For Chinese it's not possible to do due to number range I think, but for Latin the it's possible and faster.