-
Notifications
You must be signed in to change notification settings - Fork 122
Expose styling options for the user location annotation. #403
Conversation
@@ -313,6 +313,8 @@ NS_ASSUME_NONNULL_BEGIN | |||
*/ | |||
- (void)mapViewDidStopLocatingUser:(MGLMapView *)mapView; | |||
|
|||
- (MGLUserLocationStyle)mapViewStyleForUserLocationView:(MGLMapView *)mapView; |
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.
MGLUserLocationStyle appears to be specific to MGLFaux3DUserLocationAnnotationView. If the developer provides a custom view in -mapView:viewForAnnotation:
, the return value of this method is ignored. Is there a more generic way to make MGLFaux3DUserLocationAnnotationView more stylable? How about a simple delegate method that says the view will get updated based on a new location? Or more generically, a method that says any annotation view will be updated by the map view?
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.
You are right. This delegate method will be ignored if the users implements a custom location annotation view. We use a single annotation view to render four types of visual representations. Using a styling object was IMO the best tradeoff to handle this. I am not sure we may want to change rendering individually each visual representation for Hydrogen.
Perhaps changing the name to mapViewStyleForDefaultUserLocationAnnotationView:
may sound more explicit?
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.
Don't forget the changelog 🙃
platform/ios/app/MBXViewController.m
Outdated
@@ -2366,6 +2366,25 @@ - (void)mapView:(nonnull MGLMapView *)mapView didChangeLocationManagerAuthorizat | |||
} | |||
} | |||
|
|||
- (MGLUserLocationStyle)mapViewStyleForUserLocationView:(MGLMapView *)mapView { |
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.
How would you envision this working if the developer wanted to dynamically change the default user location annotation color? When we make an ios-sdk-examples
entry for this, we should highlight this kind of use case.
@@ -313,6 +313,8 @@ NS_ASSUME_NONNULL_BEGIN | |||
*/ | |||
- (void)mapViewDidStopLocatingUser:(MGLMapView *)mapView; | |||
|
|||
- (MGLUserLocationStyle)mapViewStyleForUserLocationView:(MGLMapView *)mapView; |
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.
This method should be documented. If we don't want the documentation to appear in the API guides, prepend the documentation entry with :nodoc:
.
In the documentation, we should note that setting the map view's tintColor
does not have an effect on this default user location annotation color, as it once did.
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.
This was a work in progress. I added the documentation.
platform/ios/src/MGLMapView.h
Outdated
/** | ||
A structure containing information about the default User Location view style. | ||
*/ | ||
typedef struct __attribute__((objc_boxable)) MGLUserLocationStyle { |
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.
I would encourage documenting each of these properties so that the developer has a good sense of what parts of the user location annotation are changing - some things like the approximate
properties are new and perhaps not widely understood yet.
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.
I added the documentation.
745d331
to
b87f0a2
Compare
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.
Thanks for adding additional documentation, this is very helpful. I have two minor concerns but otherwise this looks good.
@interface MGLUserLocationAnnotationViewStyle : NSObject | ||
|
||
/** | ||
The puck's view fill color. |
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.
The puck view's fill color.
or, since the possessive form of "view" feels odd here, maybe:
The fill color for the puck view.
*/ | ||
@property (nonatomic) UIColor *haloFillColor; | ||
/** | ||
The approximate's view halo fill color. |
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.
I think The halo fill color for the approximate view
makes more sense (and for the rest of the properties below).
/** | ||
The approximate's view halo fill color. | ||
*/ | ||
@property (nonatomic) UIColor *approximateHaloFillColor; |
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.
Should we note that any properties for the approximate view will only work in iOS 14+ when the user has enabled approximate location?
* master: Release 6.2.0 beta.1 prep (#417) Update for Xcode 12 release (#415) Switch background snapshot to periodic. (#412) Fix map stuttering by switching render call to use setNeedsDisplay (#411) Add a flag to enforce using catched tiles (#416) Improve header documentation for MGLObservable (#398) Expose styling options for the user location annotation. (#403)
Fixes #385
Styling example:
Halo
Arrow
Puck
Approximate