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?