Skip to content

feat: Add map bounds support #148

Open
arturgesiarz wants to merge 11 commits intomainfrom
143-determine-map-bounds-from-current-camera-position
Open

feat: Add map bounds support #148
arturgesiarz wants to merge 11 commits intomainfrom
143-determine-map-bounds-from-current-camera-position

Conversation

@arturgesiarz
Copy link
Member

Add basic version of bounds

Add bounds support to all platforms

@arturgesiarz
Copy link
Member Author

arturgesiarz commented Mar 3, 2026

Copy link
Contributor

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

Adds first-class “visible map bounds” support to the shared CameraPosition model and wires bounds capture/application across Android, iOS (Google Maps + MapKit), and the JVM/web Google Maps wrapper.

Changes:

  • Introduces MapBounds and adds optional bounds to CameraPosition (serializable for the web bridge).
  • Updates Android/iOS camera conversion paths to include visible bounds in onCameraMove and to apply bounds when setting the camera.
  • Extends the web (JVM) JS bridge payload to report bounds, and updates sample defaults to include bounds.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
kmp-maps/core/src/commonMain/kotlin/com/swmansion/kmpmaps/core/MapTypes.kt Adds MapBounds + CameraPosition.bounds.
kmp-maps/core/src/androidMain/kotlin/com/swmansion/kmpmaps/core/Map.kt Computes viewport size and uses bounds-aware camera updates + includes bounds in onCameraMove.
kmp-maps/core/src/androidMain/kotlin/com/swmansion/kmpmaps/core/Extensions.kt Adds bounds ↔ native conversions and bounds-aware camera updates.
kmp-maps/core/src/androidMain/kotlin/com/swmansion/kmpmaps/core/Utils.kt Adds Mercator-based zoom calculation helper.
kmp-maps/core/src/iosMain/kotlin/com/swmansion/kmpmaps/core/Extensions.kt MapKit region conversions now consider bounds and emit bounds.
kmp-maps/google-maps/src/iosMain/kotlin/com/swmansion/kmpmaps/googlemaps/Extensions.kt Applies bounds via fitBounds and adds visible-bounds extraction helper.
kmp-maps/google-maps/src/iosMain/kotlin/com/swmansion/kmpmaps/googlemaps/MapDelegate.kt Includes visible bounds in emitted camera updates.
kmp-maps/core/src/jvmMain/resources/web/google_map.js Emits bounds in the JS → Kotlin camera payload.
kmp-maps/core/src/jvmMain/kotlin/com/swmansion/kmpmaps/core/MapContentLoader.kt Centers initial web camera from bounds midpoint.
sample/src/commonMain/kotlin/com/swmansion/kmpmaps/sample/MapWrapper.kt Updates sample default camera to include bounds.
.gitignore Ignores .claude.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

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

Copilot reviewed 9 out of 10 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

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

Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +302 to +303
bearing = (position.iosCameraPosition?.gmsBearing ?: 0f).toDouble(),
viewingAngle = (position.iosCameraPosition?.gmsViewingAngle ?: 0f).toDouble(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
bearing = (position.iosCameraPosition?.gmsBearing ?: 0f).toDouble(),
viewingAngle = (position.iosCameraPosition?.gmsViewingAngle ?: 0f).toDouble(),
bearing = position.iosCameraPosition?.gmsBearing?.toDouble() ?: 0.0,
viewingAngle = position.iosCameraPosition?.gmsViewingAngle?.toDouble() ?: 0.0,

Comment on lines 74 to 80
const cameraState = {
coordinates: {
latitude: center.lat(),
longitude: center.lng(),
},
zoom
};
Copy link
Contributor

Choose a reason for hiding this comment

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

790672b added a bounds entry here. In 5b03e0c, this was reverted, and {{FIT_BOUNDS_CALL}} was added above. Shouldn’t both be present? One sets the initial camera position; the other reports back the current bounds on camera move.

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.

Need to be able to determine map bounds from current camera position

3 participants