-
-
Notifications
You must be signed in to change notification settings - Fork 6
feat: add pitch and bearing camera controls #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This adds horizontal sliders to control map pitch (tilt) and bearing (rotation). The sliders are positioned in the top toolbar alongside the existing buttons. Changes: - Add set_pitch() and set_bearing() methods to SlintMapLibre - Add camera.hpp include for CameraOptions - Wire up callbacks in main.cpp for pitch/bearing controls - Add pitch and bearing sliders to top toolbar in UI - Use MapLibre terminology (pitch/bearing) for consistency with API - Keep original VerticalBox layout structure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds pitch (tilt) and bearing (rotation) camera controls to the map interface via horizontal sliders in the top toolbar. The implementation follows MapLibre's standard terminology and integrates with the existing camera control system.
- Adds new SlintMapLibre methods for setting pitch and bearing with appropriate value conversion
- Implements callback handlers in main.cpp to connect UI controls to map functionality
- Extends the UI with pitch and bearing sliders alongside existing navigation buttons
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/slint_maplibre_headless.hpp | Declares new set_pitch() and set_bearing() methods |
| src/slint_maplibre_headless.cpp | Implements camera control methods with value conversion and state preservation |
| examples/map_window.slint | Adds pitch and bearing sliders with labels to the top toolbar |
| examples/main.cpp | Wires up callback handlers for the new camera controls |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| void SlintMapLibre::set_pitch(int pitch_value) { | ||
| if (!map) | ||
| return; | ||
| // Convert slider value (0-100) to pitch in degrees (0-60) | ||
| double pitch = (pitch_value / 100.0) * 60.0; | ||
|
|
||
| // Get current camera state and update pitch | ||
| const auto cam = map->getCameraOptions(); | ||
| mbgl::CameraOptions next; | ||
| next.withCenter(cam.center) | ||
| .withZoom(cam.zoom) | ||
| .withBearing(cam.bearing) | ||
| .withPitch(std::optional<double>(pitch)); |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing include for camera.hpp as mentioned in the PR description. The CameraOptions class requires this include to be properly defined.
| if (!map) | ||
| return; | ||
| // Convert slider value (0-100) to pitch in degrees (0-60) | ||
| double pitch = (pitch_value / 100.0) * 60.0; |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Magic number 60.0 should be defined as a named constant (e.g., MAX_PITCH_DEGREES) to improve code readability and maintainability.
| if (!map) | ||
| return; | ||
| // Convert slider value (0-100) to bearing in degrees (0-360) | ||
| double bearing = (bearing_value / 100.0) * 360.0; |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Magic number 360.0 should be defined as a named constant (e.g., MAX_BEARING_DEGREES) to improve code readability and maintainability.
yuiseki
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I feel change pitch by slider is very good example for maplibre native with slint integration!
Thanks!
This adds horizontal sliders to control map pitch (tilt) and bearing (rotation). The sliders are positioned in the top toolbar alongside the existing buttons.
Changes:
Description
(A brief description of the changes in this pull request)
Todos
Screenshots
(If applicable, screenshots of the changes)