用于显示 2D 文本符号和 3D 文本符号的字体。此类允许开发人员设置字体 family、decoration、size、style 和 weight 属性。请注意每个属性的“已知限制”,以了解它们如何根据图层类型以及您是否使用 MapView 或 SceneView 而有所不同。
let textSymbol = {
type: "text", // autocasts as new TextSymbol()
color: "white",
haloColor: "black",
haloSize: "1px",
text: "You are here",
xoffset: 3,
yoffset: 3,
font: { // autocasts as new Font()
size: 12,
family: "Josefin Slab",
weight: "bold"
}
};
构造函数
属性概述
名称 | 类型 | 描述 | 类 |
---|---|---|---|
String | 类的名称。 更多详情 | Accessor | |
String | 文本修饰符。 更多详情 | Font | |
String | 文本的字体系列。 更多详情 | Font | |
Number | 字体大小(以磅为单位)。 更多详情 | Font | |
String | 文本样式。 更多详情 | Font | |
String | 文本粗细。 更多详情 | Font |
属性详细信息
-
起始版本:GeoScene Maps SDK for JavaScript 4.7
-
类的名称。声明的类名称格式化为
geoscene.folder.className
。
-
decoration String
-
文本修饰符。
可能值:"underline"|"line-through"|"none"
- 默认值:none
-
family String
-
文本的字体系列。可能值取决于图层类型,以及您使用的是 MapView 还是 SceneView。有关详细说明,请参阅标注指南页面,或单击下面的
Read more
。3D SceneViews 的字体系列
3D SceneViews 支持的字体系列取决于安装在用户计算机和 Web 浏览器上的字体。如果应用程序使用了未安装的字体,Font 类将实现一个回退机制,该机制将使用默认字体系列值,即
sans-serif
。有关如何在 Windows 或 Mac 上安装新字体的说明,请参阅这些参考资料。本地未安装的字体也可通过在 css 文件中定义 @font-face 并从符号层中的
family
属性引用它来从 url 加载。2D MapImageLayer 的字体系列
MapView 中的 MapImageLayers 支持的字体系列取决于安装在发布图层的 GeoScene Server 上的字体。如果应用程序使用了未安装的字体,Font 类将实现一个回退机制,该机制将使用默认字体系列值,即
sans-serif
。2D FeatureLayer、CSVLayer、StreamLayer 和 TextSymbol 的字体系列
支持的字体系列基于
.pbf
格式的托管字体文件。默认情况下,可用字体大多与 GeoScene 矢量底图使用的字体相同。这些字体可通过https://static.geoscene.cn/fonts
获得。通过设置 geosceneConfig.fontsUrl 属性,可以将 URL 配置为指向您自己的字体资源。如果应用程序使用了未安装的字体,Font 类将实现一个回退机制,该机制将使用默认字体系列值,即sans-serif
。这使用Arial Unicode MS
字体文件。标注概述页面中提供了下表中列出的字体的预览。
2D MapView 中当前支持的字体列表:
字体 样式 子重 代码段 Abril Fatface Regular normal normal font: { family: 'Abril Fatface', style: 'normal', weight: 'normal' } Alegreya Bold normal bold font: { family: 'Alegreya', style: 'normal', weight: 'bold' } Alegreya Bold Italic italic bold font: { family: 'Alegreya', style: 'italic', weight: 'bold' } Alegreya Italic italic normal font: { family: 'Alegreya', style: 'italic', weight: 'normal' } Alegreya Regular normal normal font: { family: 'Alegreya', style: 'normal', weight: 'normal' } Alegreya SC Bold normal bold font: { family: 'Alegreya SC', style: 'normal', weight: 'bold' } Alegreya SC Italic italic normal font: { family: 'Alegreya SC', style: 'italic', weight: 'normal' } Alegreya SC Regular normal normal font: { family: 'Alegreya SC', style: 'normal', weight: 'normal' } Alegreya Sans Italic italic normal font: { family: 'Alegreya Sans', style: 'italic', weight: 'normal' } Amarante Regular normal normal font: { family: 'Amarante', style: 'normal', weight: 'normal' } Amatic SC Bold normal bold font: { family: 'Amatic SC', style: 'normal', weight: 'bold' } Arial Bold normal bold font: { family: 'Arial', style: 'normal', weight: 'bold' } Arial Bold Italic italic bold font: { family: 'Arial', style: 'italic', weight: 'bold' } Arial Italic italic normal font: { family: 'Arial', style: 'italic', weight: 'normal' } Arial Regular normal normal font: { family: 'Arial', style: 'normal', weight: 'normal' } Arial Unicode MS Bold normal bold font: { family: 'Arial Unicode MS', style: 'normal', weight: 'bold' } Arial Unicode MS Regular normal normal font: { family: 'Arial Unicode MS', style: 'normal', weight: 'normal' } Atomic Age Regular normal normal font: { family: 'Atomic Age', style: 'normal', weight: 'normal' } Audiowide Regular normal normal font: { family: 'Audiowide', style: 'normal', weight: 'normal' } Avenir Next LT Pro Bold normal bold font: { family: 'Avenir Next LT Pro', style: 'normal', weight: 'bold' } Avenir Next LT Pro Bold Italic italic bold font: { family: 'Avenir Next LT Pro', style: 'italic', weight: 'bold' } Avenir Next LT Pro Demi Italic italic normal font: { family: 'Avenir Next LT Pro Demi', style: 'italic', weight: 'normal' } Avenir Next LT Pro Italic italic normal font: { family: 'Avenir Next LT Pro', style: 'italic', weight: 'normal' } Avenir Next LT Pro Light normal normal font: { family: 'Avenir Next LT Pro Light', style: 'normal', weight: 'normal' } Avenir Next LT Pro Light Italic italic normal font: { family: 'Avenir Next LT Pro Light', style: 'italic', weight: 'normal' } Avenir Next LT Pro Medium Bold normal bold font: { family: 'Avenir Next LT Pro Medium', style: 'normal', weight: 'bold' } Avenir Next LT Pro Medium Bold Italic italic bold font: { family: 'Avenir Next LT Pro Medium', style: 'italic', weight: 'bold' } Avenir Next LT Pro Regular normal normal font: { family: 'Avenir Next LT Pro', style: 'normal', weight: 'normal' } Avenir Next LT Pro Regular Bold normal bold font: { family: 'Avenir Next LT Pro Regular', style: 'normal', weight: 'bold' } BellTopo Sans Bold normal bold font: { family: 'BellTopo Sans', style: 'normal', weight: 'bold' } BellTopo Sans Bold Italic italic bold font: { family: 'BellTopo Sans', style: 'italic', weight: 'bold' } BellTopo Sans Italic italic normal font: { family: 'BellTopo Sans', style: 'italic', weight: 'normal' } BellTopo Sans Regular normal normal font: { family: 'BellTopo Sans', style: 'normal', weight: 'normal' } Belleza Regular normal normal font: { family: 'Belleza', style: 'normal', weight: 'normal' } Black Ops One Regular normal normal font: { family: 'Black Ops One', style: 'normal', weight: 'normal' } Cabin Sketch Bold normal bold font: { family: 'Cabin Sketch', style: 'normal', weight: 'bold' } Cabin Sketch Regular normal normal font: { family: 'Cabin Sketch', style: 'normal', weight: 'normal' } Coming Soon Regular normal normal font: { family: 'Coming Soon', style: 'normal', weight: 'normal' } FGDC GeoAge Regular normal normal font: { family: 'FGDC GeoAge', style: 'normal', weight: 'normal' } Homemade Apple Regular normal normal font: { family: 'Homemade Apple', style: 'normal', weight: 'normal' } IM FELL DW Pica PRO Italic italic normal font: { family: 'IM FELL DW Pica PRO', style: 'italic', weight: 'normal' } IM FELL DW Pica PRO Regular normal normal font: { family: 'IM FELL DW Pica PRO', style: 'normal', weight: 'normal' } Josefin Sans Regular normal normal font: { family: 'Josefin Sans', style: 'normal', weight: 'normal' } Josefin Sans Semibold Italic italic bold font: { family: 'Josefin Sans Semibold', style: 'italic', weight: 'bold' } Josefin Slab Bold normal bold font: { family: 'Josefin Slab', style: 'normal', weight: 'bold' } Josefin Slab Bold Italic italic bold font: { family: 'Josefin Slab', style: 'italic', weight: 'bold' } Josefin Slab Italic italic normal font: { family: 'Josefin Slab', style: 'italic', weight: 'normal' } Josefin Slab Light Italic italic normal font: { family: 'Josefin Slab Light', style: 'italic', weight: 'normal' } Josefin Slab Regular normal normal font: { family: 'Josefin Slab', style: 'normal', weight: 'normal' } Josefin Slab Semibold Italic italic bold font: { family: 'Josefin Slab Semibold', style: 'italic', weight: 'bold' } Josefin Slab Thin Italic italic normal font: { family: 'Josefin Slab Thin', style: 'italic', weight: 'normal' } Just Another Hand Regular normal normal font: { family: 'Just Another Hand', style: 'normal', weight: 'normal' } Kranky Regular normal normal font: { family: 'Kranky', style: 'normal', weight: 'normal' } Life Savers Bold normal bold font: { family: 'Life Savers', style: 'normal', weight: 'bold' } Loved by the King Regular normal normal font: { family: 'Loved by the King', style: 'normal', weight: 'normal' } Merriweather Bold normal bold font: { family: 'Merriweather', style: 'normal', weight: 'bold' } Merriweather Bold Italic italic bold font: { family: 'Merriweather', style: 'italic', weight: 'bold' } Merriweather Italic italic normal font: { family: 'Merriweather', style: 'italic', weight: 'normal' } Merriweather Regular normal normal font: { family: 'Merriweather', style: 'normal', weight: 'normal' } Montserrat Bold normal bold font: { family: 'Montserrat', style: 'normal', weight: 'bold' } Montserrat Italic italic normal font: { family: 'Montserrat', style: 'italic', weight: 'normal' } Montserrat Medium Italic italic normal font: { family: 'Montserrat Medium', style: 'italic', weight: 'normal' } Montserrat Regular normal normal font: { family: 'Montserrat', style: 'normal', weight: 'normal' } Montserrat Semibold Italic italic bold font: { family: 'Montserrat Semibold', style: 'italic', weight: 'bold' } Noto Sans Bold normal bold font: { family: 'Noto Sans', style: 'normal', weight: 'bold' } Noto Sans Bold Italic italic bold font: { family: 'Noto Sans', style: 'italic', weight: 'bold' } Noto Sans Italic italic normal font: { family: 'Noto Sans', style: 'italic', weight: 'normal' } Noto Sans Regular normal normal font: { family: 'Noto Sans', style: 'normal', weight: 'normal' } Noto Serif Bold normal bold font: { family: 'Noto Serif', style: 'normal', weight: 'bold' } Noto Serif Bold Italic italic bold font: { family: 'Noto Serif', style: 'italic', weight: 'bold' } Noto Serif Italic italic normal font: { family: 'Noto Serif', style: 'italic', weight: 'normal' } Noto Serif Regular normal normal font: { family: 'Noto Serif', style: 'normal', weight: 'normal' } Old Standard TT Bold normal bold font: { family: 'Old Standard TT', style: 'normal', weight: 'bold' } Old Standard TT Italic italic normal font: { family: 'Old Standard TT', style: 'italic', weight: 'normal' } Old Standard TT Regular normal normal font: { family: 'Old Standard TT', style: 'normal', weight: 'normal' } Orbitron Bold normal bold font: { family: 'Orbitron', style: 'normal', weight: 'bold' } Orbitron Regular normal normal font: { family: 'Orbitron', style: 'normal', weight: 'normal' } Oregano Italic italic normal font: { family: 'Oregano', style: 'italic', weight: 'normal' } Oregano Regular normal normal font: { family: 'Oregano', style: 'normal', weight: 'normal' } Oswald Bold normal bold font: { family: 'Oswald', style: 'normal', weight: 'bold' } Oswald Regular normal normal font: { family: 'Oswald', style: 'normal', weight: 'normal' } Pacifico Regular normal normal font: { family: 'Pacifico', style: 'normal', weight: 'normal' } Palatino Linotype Regular normal normal font: { family: 'Palatino Linotype', style: 'normal', weight: 'normal' } Playfair Display Black normal normal font: { family: 'Playfair Display Black', style: 'normal', weight: 'normal' } Playfair Display Bold normal bold font: { family: 'Playfair Display', style: 'normal', weight: 'bold' } Playfair Display Bold Italic italic bold font: { family: 'Playfair Display', style: 'italic', weight: 'bold' } Playfair Display Italic italic normal font: { family: 'Playfair Display', style: 'italic', weight: 'normal' } Playfair Display Regular normal normal font: { family: 'Playfair Display', style: 'normal', weight: 'normal' } Playfair Display SC Bold normal bold font: { family: 'Playfair Display SC', style: 'normal', weight: 'bold' } Playfair Display SC Regular normal normal font: { family: 'Playfair Display SC', style: 'normal', weight: 'normal' } Redressed Regular normal normal font: { family: 'Redressed', style: 'normal', weight: 'normal' } Risque Regular normal normal font: { family: 'Risque', style: 'normal', weight: 'normal' } Roboto Condensed Italic italic normal font: { family: 'Roboto Condensed', style: 'italic', weight: 'normal' } Roboto Condensed Light Italic italic normal font: { family: 'Roboto Condensed Light', style: 'italic', weight: 'normal' } Rye Regular normal normal font: { family: 'Rye', style: 'normal', weight: 'normal' } Special Elite Regular normal normal font: { family: 'Special Elite', style: 'normal', weight: 'normal' } Syncopate Bold normal bold font: { family: 'Syncopate', style: 'normal', weight: 'bold' } Syncopate Regular normal normal font: { family: 'Syncopate', style: 'normal', weight: 'normal' } Tangerine Regular normal normal font: { family: 'Tangerine', style: 'normal', weight: 'normal' } Ubuntu Bold normal bold font: { family: 'Ubuntu', style: 'normal', weight: 'bold' } Ubuntu Bold Italic italic bold font: { family: 'Ubuntu', style: 'italic', weight: 'bold' } Ubuntu Condensed Regular normal normal font: { family: 'Ubuntu Condensed', style: 'normal', weight: 'normal' } Ubuntu Italic italic normal font: { family: 'Ubuntu', style: 'italic', weight: 'normal' } Ubuntu Light normal normal font: { family: 'Ubuntu Light', style: 'normal', weight: 'normal' } Ubuntu Light Bold normal bold font: { family: 'Ubuntu Light', style: 'normal', weight: 'bold' } Ubuntu Light Bold Italic italic bold font: { family: 'Ubuntu Light', style: 'italic', weight: 'bold' } Ubuntu Light Italic italic normal font: { family: 'Ubuntu Light', style: 'italic', weight: 'normal' } Ubuntu Medium Italic italic normal font: { family: 'Ubuntu Medium', style: 'italic', weight: 'normal' } Ubuntu Mono Bold normal bold font: { family: 'Ubuntu Mono', style: 'normal', weight: 'bold' } Ubuntu Mono Bold Italic italic bold font: { family: 'Ubuntu Mono', style: 'italic', weight: 'bold' } Ubuntu Mono Italic italic normal font: { family: 'Ubuntu Mono', style: 'italic', weight: 'normal' } Ubuntu Mono Regular normal normal font: { family: 'Ubuntu Mono', style: 'normal', weight: 'normal' } Ubuntu Regular normal normal font: { family: 'Ubuntu', style: 'normal', weight: 'normal' } UnifrakturCook Bold normal bold font: { family: 'UnifrakturCook', style: 'normal', weight: 'bold' } Vast Shadow Regular normal normal font: { family: 'Vast Shadow', style: 'normal', weight: 'normal' } Walter Turncoat Regular normal normal font: { family: 'Walter Turncoat', style: 'normal', weight: 'normal' } - 默认值:sans-serif
- 另请参阅
示例let textSymbol = { type: "text", // autocasts as new TextSymbol() text: "Science of Where", font: { // autocasts as new Font() family: "Merriweather", size: 12, style: "italic", weight: "bold" } };
-
字体大小(以磅为单位)。此值可以是自动转换的,其字符串以磅或像素表示大小 (例如
12px
)。已知限制
在 3D SceneViews 中,如果设置了 TextSymbol3DLayer.size 属性,它将覆盖此 size 属性。
- 默认值:9
- 另请参阅
示例// size in points symbol.size = 14;
// size in pixels symbol.size = "20px";
// size in points symbol.size = "14pt";
-
style String
-
文本样式。指定是否应设置字体样式:正常、斜体或倾斜。
已知限制
oblique
在以下环境中不受支持:2D FeatureLayer、CSVLayer 和 StreamLayer 标注。可能值:"normal"|"italic"|"oblique"
- 默认值:normal
- 另请参阅
-
weight String
-
文本粗细。指定粗体级别。
已知限制
bolder
和lighter
在以下环境中不受支持:2D FeatureLayer、CSVLayer 和 StreamLayer 标注。可能值:"normal"|"bold"|"bolder"|"lighter"
- 默认值:normal
- 另请参阅
方法概述
名称 | 返回值类值 | 描述 | 类 |
---|---|---|---|
添加一个或多个与对象的生命周期相关联的句柄。 更多详情 | Accessor | ||
Font | 创建 font 对象的深度克隆。 更多详情 | Font | |
* | 创建此类的新实例并使用从 GeoScene 产品生成的 JSON 对象值对其进行初始化。 更多详情 | Font | |
Boolean | 如果存在指定的句柄组,则返回 true。 更多详情 | Accessor | |
移除对象拥有的句柄组。 更多详情 | Accessor | ||
Object | 将此类的实例转换为 GeoScene Portal JSON 表示。 更多详情 | Font |
方法详细说明
-
addHandles(handleOrHandles, groupKey)inherited起始版本:GeoScene Maps SDK for JavaScript 4.25
-
添加一个或多个与对象的生命周期相关联的句柄。当对象被销毁时,将移除句柄。
// Manually manage handles const handle = reactiveUtils.when( () => !view.updating, () => { wkidSelect.disabled = false; }, { once: true } ); // Handle gets removed when the object is destroyed. this.addHandles(handle);
参数handleOrHandles WatchHandle|WatchHandle[]对象销毁后,标记为要移除的句柄。
groupKey *optional标识句柄应添加到的组的键。组中的所有句柄稍后都可使用 Accessor.removeHandles() 进行删除。如果未提供键,则句柄将被添加到默认组。
-
fromJSON(json){*}static
-
创建此类的新实例并使用从 GeoScene 产品生成的 JSON 对象值对其进行初始化。传入到输入
json
参数的对象通常来自对 REST API 中查询操作的响应或来自另一个 GeoScene 产品的 toJSON() 方法。有关何时以及如何使用该函数的详细信息和示例,请参阅指南中的使用 fromJSON() 主题。参数json ObjectGeoScene 格式实例的 JSON 表示。有关各种输入 JSON 对象的结构示例,请参阅 GeoScene REST API 文档。
返回类型 描述 * 返回该类的新实例。
-
起始版本:GeoScene Maps SDK for JavaScript 4.25
-
如果存在指定的句柄组,则返回 true。
参数groupKey *optional组键。
返回类型 描述 Boolean 如果存在指定的句柄组,则返回 true
。示例// Remove a named group of handles if they exist. if (obj.hasHandles("watch-view-updates")) { obj.removeHandles("watch-view-updates"); }
-
removeHandles(groupKey)inherited起始版本:GeoScene Maps SDK for JavaScript 4.25
-
移除对象拥有的句柄组。
参数groupKey *optional要移除的组键或组键的数组或集合。
示例obj.removeHandles(); // removes handles from default group obj.removeHandles("handle-group"); obj.removeHandles("other-handle-group");
-
toJSON(){Object}
-
将此类的实例转换为 GeoScene Portal JSON 表示。有关详细信息,请参阅使用 fromJSON() 指南主题。
返回类型 描述 Object 此类实例的 GeoScene Portal JSON 表示。