-
Notifications
You must be signed in to change notification settings - Fork 35
Add custom user location annotation example #30
Conversation
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/ |
if (!_dot) { | ||
_dot = [CALayer layer]; | ||
_dot.bounds = CGRectMake(0, 0, _size, _size); | ||
_dot.position = CGPointMake(_size / 2, _size / 2); |
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.
Setting frame would be simpler than setting both bounds and position.
|
||
override func update() { | ||
if CGRectIsNull(frame) { | ||
frame = CGRectMake(0, 0, size, size) |
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.
Use the Swift-style initializer instead of the C-style function.
var arrow: CAShapeLayer! | ||
|
||
override func update() { | ||
if CGRectIsNull(frame) { |
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.
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 |
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 will need to be updated for Swift 3.
→ #50 |
Adds a custom user location example.
Todo
/cc @1ec5 @frederoni