0

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?

4

1 回答 1

0

我不认为这是可能的访问。文本布局计算深埋在 mapbox-gl 源代码中。文本本身使用距离字段字体在 WebGL 中呈现

于 2019-02-26T20:05:34.957 回答