javascript - How to find the width of a text-field in symbol type in mapbox
问题描述
I am trying to get the width of a text-field in coordinates, i.e. starting coordinates and ending coordinates of the text-field on the map. My code is as below:
map.on('load', function () {
map.addLayer({
"id": "labels",
"type": "symbol",
"source": {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-119.4179, 36.7783]
}
}]
}
},
"layout": {
"icon-image": "harbor-15",
"text-field": "Testing city name",
"text-font": ["Open Sans Semibold", "Arial Unicode MS Bold"],
"text-offset": [0, 0.6],
"text-anchor": "top",
"text-allow-overlap": true
}
});
From the above, I would like to get the exact start and end coordinates of the text-field only. Could somebody say whether this is possible?
解决方案
我不认为这是可能的访问。文本布局计算深埋在 mapbox-gl 源代码中。文本本身使用距离字段字体在 WebGL 中呈现
推荐阅读
- java - 进程资源包 maven 错误 calssnotfoundexception org.apache.commons.collections.ExtendedProperties
- javascript - 使用哈希滚动时更改 url
- javascript - 返回按钮返回登录页面而不是角度 4 中的主页
- python - 重叠多边形时地理熊猫的空间连接?
- dataframe - 如何在闪亮的应用程序上将数据框作为数据表项返回
- sql-server - 对列内容进行聚合的列元数据查询
- java - FileChoose 被打开了两次
- c# - WPF CustomControl 样式未由子控件继承
- javascript - addEventListener 中的变量不起作用
- scala - 如何初始化类型别名的空映射