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

Add custom user location annotation example #30

Closed
wants to merge 9 commits into from

Conversation

friedbunny
Copy link
Contributor

@friedbunny friedbunny commented Aug 19, 2016

Adds a custom user location example.

Todo

  • Objective-C
  • Cleanup and review.

/cc @1ec5 @frederoni

@friedbunny
Copy link
Contributor Author

Converted this to a clone of the Google (and new Apple) style, with a heading indicator arrow that rotates around the outside. Still blocked by mapbox/mapbox-gl-native#5523 when it comes to always showing the heading without also rotating the map w/MGLUserTrackingModeFollowWithHeading, but perhaps we can manage without that initially.

img_4475

@friedbunny
Copy link
Contributor Author

Added an arc to the bottom of the arrow:

img_4476

Enlarged to show texture. Serving suggestion. No artificial colors or flavors.

if (!_dot) {
_dot = [CALayer layer];
_dot.bounds = CGRectMake(0, 0, _size, _size);
_dot.position = CGPointMake(_size / 2, _size / 2);
Copy link
Contributor

Choose a reason for hiding this comment

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

Setting frame would be simpler than setting both bounds and position.


override func update() {
if CGRectIsNull(frame) {
frame = CGRectMake(0, 0, size, size)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use the Swift-style initializer instead of the C-style function.

var arrow: CAShapeLayer!

override func update() {
if CGRectIsNull(frame) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Best practice is to use a guard statement to make the intended main code path clearer.

dot.cornerRadius = size / 2
dot.backgroundColor = super.tintColor.CGColor
dot.borderWidth = 2
dot.borderColor = UIColor.whiteColor().CGColor
Copy link
Contributor

Choose a reason for hiding this comment

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

This will need to be updated for Swift 3.

@friedbunny
Copy link
Contributor Author

Alternatively moving in #50 w/@mayagao.

@friedbunny friedbunny mentioned this pull request Feb 9, 2017
@friedbunny
Copy link
Contributor Author

#50

@friedbunny friedbunny closed this Mar 29, 2017
@friedbunny friedbunny deleted the fb-user-location-annotation branch March 29, 2017 04:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants