Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Expose styling options for the user location annotation. #403

Merged
merged 7 commits into from
Sep 3, 2020

Conversation

fabian-guerra
Copy link
Contributor

@fabian-guerra fabian-guerra commented Aug 31, 2020

Fixes #385

Styling example:

Halo

puck_halo

Arrow

arrow

Puck

puck

Approximate

aproximate

@@ -313,6 +313,8 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (void)mapViewDidStopLocatingUser:(MGLMapView *)mapView;

- (MGLUserLocationStyle)mapViewStyleForUserLocationView:(MGLMapView *)mapView;
Copy link
Contributor

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?

Copy link
Contributor Author

@fabian-guerra fabian-guerra Sep 1, 2020

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?

Copy link
Contributor

@captainbarbosa captainbarbosa left a 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 🙃

@@ -2366,6 +2366,25 @@ - (void)mapView:(nonnull MGLMapView *)mapView didChangeLocationManagerAuthorizat
}
}

- (MGLUserLocationStyle)mapViewStyleForUserLocationView:(MGLMapView *)mapView {
Copy link
Contributor

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;
Copy link
Contributor

@captainbarbosa captainbarbosa Sep 1, 2020

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.

Copy link
Contributor Author

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.

/**
A structure containing information about the default User Location view style.
*/
typedef struct __attribute__((objc_boxable)) MGLUserLocationStyle {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the documentation.

Copy link
Contributor

@captainbarbosa captainbarbosa left a 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.
Copy link
Contributor

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.
Copy link
Contributor

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;
Copy link
Contributor

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?

@fabian-guerra fabian-guerra merged commit f1d117b into master Sep 3, 2020
@fabian-guerra fabian-guerra deleted the fabian-update-ul-style branch September 3, 2020 00:14
katydecorah pushed a commit that referenced this pull request Sep 4, 2020
* 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)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Explore: Expose styling for default user location view
4 participants