mapbox / mapbox/mapbox-gl-js

How to enable Map Pitch when `dragRotate.disable()` & `touchZoomRotate.disableRotation()`

Open
#10,688 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs discussion :speech_balloon:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

**mapbox-gl-js version**:
```
"@mapbox/mapbox-gl-draw": "^1.2.2",
"@mapbox/mapbox-gl-geocoder": "^4.7.0",
"mapbox-gl": "^2.2.0",
```
### Question
How to enable pitch when dragRotate.disable() & touchZoomRotate.disableRotation() ?

I have two checkbox to enable the feature, namely `Allow Map Pitch` & `Allow Map Bearing`.
And here is a snippet of my js code:
```
if(!data.allowBearing){
map.dragRotate.disable();
map.touchZoomRotate.disableRotation();
}

if(!data.allowPitch){
map.setMaxPitch(0);
map.setMinPitch(0);
}
```
The "Allow Map Pitch" checkbox is working only if the "Allow Map Bearing" checkbox is active. How to make disable bearing but allow pitch?

I have carefully read [the documentation on the official website](https://docs.mapbox.com/mapbox-gl-js/api/), and searched for previous issues both here and from Google sources. However, I haven't found the right questions and answers.

Thank you.

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

Start with the API entry points shown in the issue: map.dragRotate.disable(), map.touchZoomRotate.disableRotation(), and the pitch limit methods. Compare their documented behavior and inspect the related interaction-handler implementation. Done means establishing whether pitch can work independently of bearing, then documenting the supported configuration or defining the needed change.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.