Skip to content

feat: use MRMapView method to track user location #12

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

12ya
Copy link
Contributor

@12ya 12ya commented Jun 6, 2025

https://files.meridianapps.com/meridian-ios-sdk/docs-6.0.0/Classes/MRMapView.html#//api/name/showsUserLocation

Summary by CodeRabbit

  • New Features
    • The map view now automatically shows or hides your current location based on location update settings, ensuring a more synchronized user experience.

Copy link

coderabbitai bot commented Jun 6, 2025

Walkthrough

The update adds logic to synchronize the display of the user's location on the map with the showLocationUpdates property. When location updates are enabled or disabled, the map's showsUserLocation property is set accordingly, and debug logs are added to reflect these state changes.

Changes

File(s) Change Summary
react-native-meridian-maps/ios/MeridianMapViewManager.m Added logic to set showsUserLocation based on showLocationUpdates and inserted debug logs.

Poem

A map now knows just when to show
Where bunny feet may softly go.
With toggles set and logs in tow,
The user's dot appears—hello!
When updates pause, it fades away—
A hopping change, hooray, hooray!
🗺️🐇


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d751605 and cca60e7.

⛔ Files ignored due to path filters (1)
  • react-native-meridian-maps/example/ios/Podfile.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • react-native-meridian-maps/ios/MeridianMapViewManager.m (4 hunks)

Comment on lines +363 to +368

// Also disable map view user location display
if (self.mapViewController.mapView) {
self.mapViewController.mapView.showsUserLocation = NO;
NSLog(@"[MeridianMapView] Disabled showsUserLocation");
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Wrap disabling of showsUserLocation on main thread
Disabling the user location display must also be performed on the main queue. Enclose this in dispatch_async(dispatch_get_main_queue(), ...) to maintain UI thread safety:

dispatch_async(dispatch_get_main_queue(), ^{
  self.mapViewController.mapView.showsUserLocation = NO;
  NSLog(@"[MeridianMapView] Disabled showsUserLocation");
});
🤖 Prompt for AI Agents
In react-native-meridian-maps/ios/MeridianMapViewManager.m around lines 363 to
368, the code disables showsUserLocation directly, which must be done on the
main thread for UI safety. Wrap the disabling of showsUserLocation and the NSLog
call inside a dispatch_async block targeting dispatch_get_main_queue() to ensure
these UI updates happen on the main thread.

Comment on lines +215 to +220
// Enable user location display if needed
if (self.showLocationUpdates) {
mapViewController.mapView.showsUserLocation = YES;
NSLog(@"[MeridianMapView] Enabled showsUserLocation on mapView (setMapViewController)");
}

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consolidate user-location logic in setMapViewController
This block duplicates the same enabling logic found elsewhere. Consider removing it and invoking updateLocationUpdates (or a shared handler) after setting the view controller to keep a single source of truth.

🤖 Prompt for AI Agents
In react-native-meridian-maps/ios/MeridianMapViewManager.m around lines 215 to
220, the code enabling user location display duplicates logic found elsewhere.
Remove this block and instead call the existing updateLocationUpdates method (or
a shared handler) after setting the mapViewController to centralize and
consolidate the user-location enabling logic in one place.

Comment on lines +342 to +347

// Also enable map view user location display
if (self.mapViewController.mapView) {
self.mapViewController.mapView.showsUserLocation = YES;
NSLog(@"[MeridianMapView] Enabled showsUserLocation (permission granted)");
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Ensure thread-safe UI updates
Toggling mapView.showsUserLocation should run on the main thread to avoid race conditions. Wrap these calls in:

dispatch_async(dispatch_get_main_queue(), ^{
  self.mapViewController.mapView.showsUserLocation = YES;
  NSLog(@"[MeridianMapView] Enabled showsUserLocation (permission granted)");
});
🤖 Prompt for AI Agents
In react-native-meridian-maps/ios/MeridianMapViewManager.m around lines 342 to
347, the code sets showsUserLocation on the mapView which updates the UI and
must be done on the main thread to avoid race conditions. Wrap the block that
sets showsUserLocation and logs the message inside a dispatch_async call to
dispatch_get_main_queue() to ensure these UI updates happen on the main thread
safely.

Comment on lines +157 to +162
// Enable user location display on the map view
if (self.showLocationUpdates) {
self.mapViewController.mapView.showsUserLocation = YES;
NSLog(@"[MeridianMapView] Enabled showsUserLocation on mapView");
}

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid duplicating showsUserLocation toggles
The map’s showsUserLocation is being enabled here and also in setMapViewController and updateLocationUpdates. Centralize this logic—e.g., call a single helper or rely solely on updateLocationUpdates—to reduce code duplication and ensure consistency.

🤖 Prompt for AI Agents
In react-native-meridian-maps/ios/MeridianMapViewManager.m around lines 157 to
162, the showsUserLocation property is being set in multiple places causing
duplication. Refactor by removing the direct setting of showsUserLocation here
and instead centralize this logic in a single method like updateLocationUpdates.
Ensure all toggling of showsUserLocation is done through that helper method to
maintain consistency and avoid redundant code.

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.

1 participant