Skip to content

Conversation

naftalibeder
Copy link
Collaborator

@naftalibeder naftalibeder commented Aug 29, 2024

Description

Fixes camera bounds-with-padding bug in v11 described in mapbox/mapbox-maps-ios#2134.

Checklist

  • I've read CONTRIBUTING.md
  • I updated the doc/other generated code with running yarn generate in the root folder
  • I have tested the new feature on /example app.
    • In V11 mode/ios
    • In New Architecture mode/ios
    • In V11 mode/android
    • In New Architecture mode/android
  • I added/updated a sample - if a new feature was implemented (/example)

@naftalibeder naftalibeder temporarily deployed to CI with Mapbox Tokens August 29, 2024 21:13 — with GitHub Actions Inactive
@naftalibeder naftalibeder had a problem deploying to CI with Mapbox Tokens August 29, 2024 21:13 — with GitHub Actions Failure
@naftalibeder naftalibeder temporarily deployed to CI with Mapbox Tokens August 29, 2024 21:13 — with GitHub Actions Inactive
@naftalibeder naftalibeder had a problem deploying to CI with Mapbox Tokens August 29, 2024 21:13 — with GitHub Actions Failure
@naftalibeder naftalibeder temporarily deployed to CI with Mapbox Tokens August 29, 2024 21:13 — with GitHub Actions Inactive
@naftalibeder naftalibeder temporarily deployed to CI with Mapbox Tokens August 29, 2024 21:13 — with GitHub Actions Inactive
@naftalibeder naftalibeder temporarily deployed to CI with Mapbox Tokens August 29, 2024 21:13 — with GitHub Actions Inactive
@naftalibeder naftalibeder temporarily deployed to CI with Mapbox Tokens September 3, 2024 19:10 — with GitHub Actions Inactive
@naftalibeder naftalibeder temporarily deployed to CI with Mapbox Tokens September 3, 2024 19:10 — with GitHub Actions Inactive
@naftalibeder naftalibeder temporarily deployed to CI with Mapbox Tokens September 3, 2024 19:10 — with GitHub Actions Inactive
@naftalibeder naftalibeder temporarily deployed to CI with Mapbox Tokens September 3, 2024 19:10 — with GitHub Actions Inactive
@naftalibeder naftalibeder temporarily deployed to CI with Mapbox Tokens September 3, 2024 19:10 — with GitHub Actions Inactive
@naftalibeder
Copy link
Collaborator Author

@mfazekas What would be required to get this merged?


map.mapView.viewport.removeStatusObserver(self)
return super.removeFromMap(map, reason:reason)
withMapView { mapView in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this on remove. Maybe just mapView?.viewport

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the comment exactly - mapView doesn't need optional chaining if acquired in the withMapView callback. What's the concern?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First it should be map.withMapView { } we're in remove so we have a RNMBXMapView we're removing from, passed in as argument .

Second if mapView of RNMBXMapView is null then what was the satusObserver was attached to? Why do we need to remove?

So I think withMapView is unnecessary in this case. Likely not harmful but you have the check carefully as it could easily keep the camera object alive, until we'll have a mapView. Which doesn't sound right, but probably no leak here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong sense of the implications of the callback architecture (_mapCallbacks.append(callback), etc.).

We can do

map._mapView.viewport.removeStatusObserver(self)

but since _mapView is force-unwrapped, I'm not sure if it could be nil when acquired that way. It'd be the only place in the camera module where map.mapView is referenced that way. Do you prefer the map._mapView syntax?

camera: .init(cameraState: .init(
center: .init(),
padding: .zero,
zoom: zoom ?? 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've found that I have more consistant results by using zoom: .zero. If zoom is set on this camera is seems to effect the positioning.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mfazekas @naftalibeder I'll aim to make a demo this afternoon of why i've highlighted this.. but when moving the camera with setCamera from a centerCoordinates position to setCamera with bounds it seems that zoom is applied to the final position. Adding this zoom: .zero looks to fix this problem thou I need to look at why.

bearing: heading ?? map.mapboxMap.cameraState.bearing,
pitch: pitch ?? map.mapboxMap.cameraState.pitch
)),
coordinatesPadding: padding,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we use coordinatePadding and not camera padding?

Gnative pushed a commit to Gnative/rnmapbox that referenced this pull request Dec 29, 2024
Gnative pushed a commit to Gnative/rnmapbox that referenced this pull request Jan 15, 2025
Gnative pushed a commit to Gnative/rnmapbox that referenced this pull request Jan 21, 2025
Gnative pushed a commit to Gnative/rnmapbox that referenced this pull request May 2, 2025
Gnative pushed a commit to Gnative/rnmapbox that referenced this pull request May 2, 2025
@naftalibeder naftalibeder had a problem deploying to CI with Mapbox Tokens June 1, 2025 15:49 — with GitHub Actions Failure
@naftalibeder naftalibeder had a problem deploying to CI with Mapbox Tokens June 1, 2025 15:49 — with GitHub Actions Failure
@naftalibeder naftalibeder had a problem deploying to CI with Mapbox Tokens June 1, 2025 15:49 — with GitHub Actions Failure
@naftalibeder naftalibeder had a problem deploying to CI with Mapbox Tokens June 1, 2025 15:49 — with GitHub Actions Failure
@naftalibeder naftalibeder had a problem deploying to CI with Mapbox Tokens June 1, 2025 15:49 — with GitHub Actions Failure
@naftalibeder naftalibeder had a problem deploying to CI with Mapbox Tokens June 1, 2025 15:49 — with GitHub Actions Failure
@naftalibeder naftalibeder had a problem deploying to CI with Mapbox Tokens June 1, 2025 15:49 — with GitHub Actions Failure
Gnative pushed a commit to Gnative/rnmapbox that referenced this pull request Jun 7, 2025
Gnative pushed a commit to Gnative/rnmapbox that referenced this pull request Sep 17, 2025
Gnative pushed a commit to Gnative/rnmapbox that referenced this pull request Oct 6, 2025
Gnative pushed a commit to Gnative/rnmapbox that referenced this pull request Oct 8, 2025
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.

3 participants