-
Notifications
You must be signed in to change notification settings - Fork 1
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,6 +154,12 @@ - (void)setupMap { | |
|
||
self.mapViewController = mapViewController; | ||
|
||
// Enable user location display on the map view | ||
if (self.showLocationUpdates) { | ||
self.mapViewController.mapView.showsUserLocation = YES; | ||
NSLog(@"[MeridianMapView] Enabled showsUserLocation on mapView"); | ||
} | ||
|
||
// Set up location manager | ||
self.appKey = [MREditorKey keyWithIdentifier:self.appId]; | ||
self.locationManager = [[MRLocationManager alloc] initWithApp:self.appKey]; | ||
|
@@ -206,6 +212,12 @@ - (void)setMapViewController:(CustomMapViewController *)mapViewController { | |
UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | ||
[self addSubview:mapViewController.view]; | ||
|
||
// Enable user location display if needed | ||
if (self.showLocationUpdates) { | ||
mapViewController.mapView.showsUserLocation = YES; | ||
NSLog(@"[MeridianMapView] Enabled showsUserLocation on mapView (setMapViewController)"); | ||
} | ||
|
||
Comment on lines
+215
to
+220
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consolidate user-location logic in 🤖 Prompt for AI Agents
|
||
// Update location updates based on current setting | ||
[self updateLocationUpdates]; | ||
|
||
|
@@ -327,6 +339,12 @@ - (void)updateLocationUpdates { | |
} else if (status == kCLAuthorizationStatusAuthorizedWhenInUse || status == kCLAuthorizationStatusAuthorizedAlways) { | ||
NSLog(@"[MeridianMapView] Starting location updates"); | ||
[self.locationManager startUpdatingLocation]; | ||
|
||
// Also enable map view user location display | ||
if (self.mapViewController.mapView) { | ||
self.mapViewController.mapView.showsUserLocation = YES; | ||
NSLog(@"[MeridianMapView] Enabled showsUserLocation (permission granted)"); | ||
} | ||
Comment on lines
+342
to
+347
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Ensure thread-safe UI updates dispatch_async(dispatch_get_main_queue(), ^{
self.mapViewController.mapView.showsUserLocation = YES;
NSLog(@"[MeridianMapView] Enabled showsUserLocation (permission granted)");
}); 🤖 Prompt for AI Agents
|
||
} else { | ||
NSLog(@"[MeridianMapView] Location permission is denied or restricted. Status: %d", status); | ||
MMEventEmitter *emitter = [self.bridge moduleForClass:[MMEventEmitter class]]; | ||
|
@@ -342,6 +360,12 @@ - (void)updateLocationUpdates { | |
} else { | ||
NSLog(@"[MeridianMapView] Stopping location updates"); | ||
[self.locationManager stopUpdatingLocation]; | ||
|
||
// Also disable map view user location display | ||
if (self.mapViewController.mapView) { | ||
self.mapViewController.mapView.showsUserLocation = NO; | ||
NSLog(@"[MeridianMapView] Disabled showsUserLocation"); | ||
} | ||
Comment on lines
+363
to
+368
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Wrap disabling of dispatch_async(dispatch_get_main_queue(), ^{
self.mapViewController.mapView.showsUserLocation = NO;
NSLog(@"[MeridianMapView] Disabled showsUserLocation");
}); 🤖 Prompt for AI Agents
|
||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
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
togglesThe map’s
showsUserLocation
is being enabled here and also insetMapViewController
andupdateLocationUpdates
. Centralize this logic—e.g., call a single helper or rely solely onupdateLocationUpdates
—to reduce code duplication and ensure consistency.🤖 Prompt for AI Agents