【问题标题】:How to find the width of a text-field in symbol type in mapbox如何在mapbox中查找符号类型中文本字段的宽度
【发布时间】:2019-02-26 18:44:24
【问题描述】:

我正在尝试获取坐标中文本字段的宽度,即地图上文本字段的起始坐标和结束坐标。我的代码如下:

        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
                }
            });

从上面,我想只获得文本字段的确切开始和结束坐标。有人能说这是否可能吗?

【问题讨论】:

    标签: javascript mapbox mapbox-gl-js mapbox-marker


    【解决方案1】:

    我认为无法访问。文本布局计算深埋在 mapbox-gl 源代码中。文本本身在 WebGL 中使用 Distance Field Fonts

    呈现

    【讨论】:

    • 感谢您的回复。有什么可以替代地图框来成功创建这个吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-03-13
    • 1970-01-01
    • 2019-11-08
    • 2018-03-25
    • 2013-01-26
    • 2020-01-13
    • 2016-09-13
    相关资源
    最近更新 更多