Skip to content

Conversation

@task-jp
Copy link
Contributor

@task-jp task-jp commented Oct 3, 2025

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

Description

(A brief description of the changes in this pull request)

Todos

  • Tests
  • Documentation
  • Changelog Entry (if applicable)

Screenshots

(If applicable, screenshots of the changes)

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
Copy link

Copilot AI left a 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.

Comment on lines +325 to +337
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));
Copy link

Copilot AI Oct 4, 2025

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.

Copilot uses AI. Check for mistakes.
if (!map)
return;
// Convert slider value (0-100) to pitch in degrees (0-60)
double pitch = (pitch_value / 100.0) * 60.0;
Copy link

Copilot AI Oct 4, 2025

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.

Copilot uses AI. Check for mistakes.
if (!map)
return;
// Convert slider value (0-100) to bearing in degrees (0-360)
double bearing = (bearing_value / 100.0) * 360.0;
Copy link

Copilot AI Oct 4, 2025

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.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@yuiseki yuiseki left a 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!

@yuiseki yuiseki merged commit fdb9039 into maplibre:main Oct 4, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants