mapbox / mapbox/mapbox-gl-js

How do I change the direction of the text-offset coordinate system with text-rotate

Open
#12,942 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged feature :green_apple:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

**mapbox-gl-js version**: 2.15.0

### Question

![image](https://github.com/mapbox/mapbox-gl-js/assets/15342069/6c3da890-d926-4fc9-9a6c-9c020e1762bf)

I want to implement the style of the corner arrows and annotations in the image above。

I find that if I change icon-rotate, the icon-offset coordinate system changes with it, but not with text。

```
layout: {
'icon-image': '0',
'icon-offset': {
stops: [
[15, [10, 0]],
[18, [20, 0]],
],
},

'icon-rotate': {
property: 'bearing_in',
stops: [
[0, 0],
[360, 360],
],
},
'text-field': [
'number-format',
['get', 'cost'],
{ 'min-fraction-digits': 1, 'max-fraction-digits': 1 },
],
'text-offset': [
'interpolate',
['linear'],
['zoom'],
15,
['literal', [0.2, 0.2]],
18,
['literal', [20, 3]],
],
'text-allow-overlap': true,
'text-rotate': {
property: 'bearing_in',
stops: [
[0, 0],
[360, 360],
],
},
'text-rotation-alignment': 'map',
'text-size': {
base: 1,
stops: [
[10, 8],
[18, 11],
],
},
'text-font': ['Arial Unicode MS Bold'],
'symbol-avoid-edges': false,
}
```
And my implementation looked like this

![image](https://github.com/mapbox/mapbox-gl-js/assets/15342069/2d8b57a9-6015-40c7-9d4d-e96b74bb7c5b)

How do I change the direction of the text-offset coordinate system with text-rotate?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file, test, or rendering entry point is named. Start by reproducing the supplied Mapbox GL JS style with text-rotate and text-offset, then trace the text placement behavior to determine whether the coordinate direction can follow rotation; done requires a verified behavior or documented limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.