Skip to content

POI screen > better map camera when far away...#118

Merged
mmathieum merged 13 commits into
masterfrom
mm/poi_screen_map_visible_area
Feb 25, 2026
Merged

POI screen > better map camera when far away...#118
mmathieum merged 13 commits into
masterfrom
mm/poi_screen_map_visible_area

Conversation

@mmathieum

@mmathieum mmathieum commented Feb 23, 2026

Copy link
Copy Markdown
Member

TODO:

  • other map marker than current POI are too big on this screen -> try using always small size?

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @mmathieum, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the map experience on the Points of Interest (POI) screen by making the map camera more dynamic and context-aware. It ensures that the map view provides a more relevant display of surrounding POIs, vehicle locations, and the user's position, especially when the user is not immediately adjacent to the main POI. Additionally, it refines how vehicle location markers are presented and updates internal data handling for better maintainability.

Highlights

  • Improved Map Camera Behavior: The map camera on the POI screen now intelligently adjusts its view to include the main POI, nearby relevant POIs, vehicle locations, and the user's device location, particularly when the user is far from the primary POI. This provides a better contextual view of the surroundings.
  • Vehicle Location Marker Enhancements: Vehicle location markers are now updated with more refined logic, including the ability to hide their snippets on the POI screen for a cleaner map view. The closest vehicle location is also used in camera calculations.
  • Code Refactoring: The getLocation() method in Module.java and POIManager.java was renamed to getLocationString() for improved clarity and consistency across the codebase. Related calls in POIArrayAdapter.java were updated accordingly.
Changelog
  • app-android/src/main/java/org/mtransit/android/data/Module.java
    • Renamed getLocation() method to getLocationString().
  • app-android/src/main/java/org/mtransit/android/data/POIArrayAdapter.java
    • Updated calls to poim.getLocation() to use poim.getLocationString().
  • app-android/src/main/java/org/mtransit/android/data/POIManager.java
    • Renamed getLocation() method to getLocationString().
  • app-android/src/main/java/org/mtransit/android/datasource/DataSourceRequestManager.kt
    • Reordered import statements.
  • app-android/src/main/java/org/mtransit/android/ui/fragment/POIFragment.java
    • Modified MapViewController initialization to manually control device location inclusion.
    • Added setupMapViewController() to configure map view controller settings, including hiding marker snippets.
    • Changed onVehicleLocationsLoaded parameter type from List to Collection.
    • Updated updateVehicleLocationMarkers call to pass additional parameters for vehicle locations.
    • Added a call to showMarkers after vehicle locations are loaded to ensure map updates.
  • app-android/src/main/java/org/mtransit/android/ui/fragment/POIFragmentExt.kt
    • Imported VehicleLocation and toLatLng extension functions.
    • Refined the logic for visibleMarkersLocationList to include more relevant POIs and device location based on distances.
    • Removed MAX_DISTANCE_TIMES constant.
    • Added getClosestVehicleLocationUuid function to find the nearest vehicle location.
  • app-android/src/main/java/org/mtransit/android/ui/fragment/POIViewModel.kt
    • Applied distinctUntilChanged() to the _vehicleLocations LiveData stream.
    • Corrected a comment for clarity.
  • app-android/src/main/java/org/mtransit/android/ui/rds/route/direction/RDSDirectionStopsFragment.kt
    • Updated updateVehicleLocationMarkers call to pass vehicleLocations.
  • app-android/src/main/java/org/mtransit/android/ui/view/MapViewController.java
    • Made lastSelectedUUID nullable and protected.
    • Added hideMapMarkerSnippet field and setHideMapMarkerSnippet() method.
    • Refactored conditional checks in showClosestPOI() and includeLocationAccuracyBounds() to be more concise.
    • Changed showMarkers() method visibility from private to public.
  • app-android/src/main/java/org/mtransit/android/ui/view/MapViewControllerExt.kt
    • Converted updateVehicleLocationMarkers to an @JvmOverloads function with optional parameters.
    • Added logic to set the initial selected UUID and show its info window.
    • Passed hideMapMarkerSnippet to marker creation and update functions.
    • Modified updateSnippet to conditionally hide the snippet based on hideMapMarkerSnippet.
  • app-android/src/main/java/org/mtransit/android/ui/view/map/GMapsExt.kt
    • Added toLatLng() extension function for Location objects.
  • app-android/src/main/java/org/mtransit/android/ui/view/map/VehicleLocationExt.kt
    • Modified getMapMarkerSnippet to combine vehicle label and timestamp.
    • Added hideSnippet parameter to marker creation and update functions to control snippet visibility.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

The pull request improves the map camera logic on the POI screen, particularly when the user is far from the POI, by including relevant context stops and the closest vehicle in the view. While the logic for selecting visible markers is improved, there are several concerns regarding the user experience (UX) where the camera might snap back or info windows might be forced open repeatedly during data updates. Additionally, a logic error was found in the construction of vehicle marker snippets, and the context stop inclusion logic is inconsistent between forward and backward directions.

mmathieum and others added 2 commits February 23, 2026 15:27
…icleLocationExt.kt

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@mmathieum mmathieum marked this pull request as ready for review February 23, 2026 20:46
@mmathieum mmathieum requested a review from Copilot February 23, 2026 20:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request improves the map camera behavior on the POI (Point of Interest) screen when viewing objects that are far away. The changes enhance how the map displays markers, particularly vehicle locations, by improving camera positioning logic and simplifying the vehicle timestamp display.

Changes:

  • Simplified vehicle location timestamp display to show minutes (with "+" indicator) for times >= 100 seconds, removing separate day/hour displays
  • Enhanced map camera logic to include device location and additional nearby POIs in visible markers calculation
  • Added ability to show info window for the closest vehicle location marker automatically
  • Added option to hide map marker snippets for cleaner display

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
strings_schedule.xml (en, fr) Removed unused time format strings and added new "minutes+" format string
VehicleLocationExt.kt Simplified timestamp display logic, modified snippet to combine label and time, added hideSnippet parameter
GMapsExt.kt Added Location.toLatLng() extension function
MapViewControllerExt.kt Enhanced updateVehicleLocationMarkers with selectedUuid parameter and boolean return type
MapViewController.java Made showMarkers public, added hideMapMarkerSnippet field, code style improvements
POIFragmentExt.kt Refactored visibleMarkersLocationList to include device location and additional POIs based on distance
POIFragment.java Added setupMapViewController, integrated closest vehicle selection and showMarkers call
POIViewModel.kt Added distinctUntilChanged() to vehicleLocations, minor comment fix
DataSourceRequestManager.kt Reordered imports alphabetically
POIManager.java, Module.java, POIArrayAdapter.java Renamed getLocation() to getLocationString() for clarity
RDSDirectionStopsFragment.kt Updated updateVehicleLocationMarkers call with new parameter
Comments suppressed due to low confidence (3)

app-android/src/main/java/org/mtransit/android/ui/view/map/VehicleLocationExt.kt:40

  • The logic for determining when to show minutes vs seconds is incorrect. With seconds >= 100L, this will show minutes after only 100 seconds (1 minute 40 seconds), but the previous logic showed days/hours/minutes appropriately. The threshold of 100 seconds seems arbitrary. Consider using a more meaningful threshold like 60 seconds (1 minute) if the intent is to simplify the display. Also note that the calculation seconds / 60 will be integer division, so precision may be lost.
                seconds >= 100L -> context.getString(R.string.short_minutes_plus_count, seconds / 60)

app-android/src/main/java/org/mtransit/android/ui/fragment/POIFragmentExt.kt:86

  • The maxVehicleDistanceInMeters calculation is overly complex and difficult to understand. The logic appears to compute the maximum of two values, where each value is constrained by the other multiplied by 3. This creates a circular dependency that makes the logic unclear. Consider simplifying to: min(poiDistanceToNextRelevantPOIM?.times(3f) ?: Float.MAX_VALUE, poiDistanceToDeviceLocationInMeters?.times(3f) ?: Float.MAX_VALUE).takeIf { it != Float.MAX_VALUE } which would take the smaller of the two distances multiplied by 3, or a clearer expression of the intended logic.
        val maxVehicleDistanceInMeters = max(
            poiDistanceToNextRelevantPOIM?.times(3f)?.coerceAtMost(poiDistanceToDeviceLocationInMeters?.times(3f) ?: Float.MAX_VALUE) ?: 0f,
            poiDistanceToDeviceLocationInMeters?.coerceAtMost(poiDistanceToNextRelevantPOIM?.times(3f) ?: Float.MAX_VALUE) ?: 0f
        ).takeIf { it > 0f }

app-android/src/main/java/org/mtransit/android/ui/fragment/POIFragmentExt.kt:92

  • The change from using sortedBy().forEach() to minByOrNull() means only the single closest vehicle location will be included in visibleMarkersLocationList, instead of potentially multiple vehicles within the max distance. This is a significant behavior change that may not be intentional. If the goal is to show all vehicles within maxVehicleDistanceInMeters, use filter instead: ?.filter { it.position.distanceToInMeters(poimLatLng) <= maxVehicleDistanceInMeters }?.forEach { add(it.position) }
        viewModel?.vehicleLocations?.value
            ?.minByOrNull { it.position.distanceToInMeters(poimLatLng) }
            ?.let { vehicleLocation ->
                if (maxVehicleDistanceInMeters != null && vehicleLocation.position.distanceToInMeters(poimLatLng) <= maxVehicleDistanceInMeters) {
                    add(vehicleLocation.position)
                }

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

Comment thread app-android/src/main/java/org/mtransit/android/ui/view/map/VehicleLocationExt.kt Outdated
@mmathieum mmathieum marked this pull request as draft February 25, 2026 14:36
@mmathieum mmathieum marked this pull request as draft February 25, 2026 14:36
@mmathieum

Copy link
Copy Markdown
Member Author

/gemini review

@mmathieum mmathieum marked this pull request as ready for review February 25, 2026 15:37

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the map view on the POI screen to provide a better camera experience, especially when the user is far from the POI. It introduces more sophisticated logic for determining which markers to display and adjusts their sizes for better clarity. Several related refactorings and cleanups are included, such as simplifying distance calculations and improving how vehicle locations are updated and displayed. My feedback focuses on improving the readability of a complex calculation.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 18 out of 18 changed files in this pull request and generated no new comments.


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

@mmathieum mmathieum merged commit 47589d5 into master Feb 25, 2026
5 of 6 checks passed
@mmathieum mmathieum deleted the mm/poi_screen_map_visible_area branch February 25, 2026 21:07
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.

POI screen> device location 🔵 should only be included in camera update if not too far.

2 participants