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

User location dot example - #50

Merged
friedbunny merged 5 commits into
masterfrom
user-location-dot
Dec 15, 2017
Merged

friedbunny merged 5 commits into
masterfrom
user-location-dot

Conversation

@mayagao

@mayagao mayagao commented Dec 15, 2016

Copy link
Copy Markdown

No description provided.

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

Copy link
Copy Markdown
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 (×4).

@1ec5 1ec5 mentioned this pull request Feb 9, 2017
@1ec5

1ec5 commented Feb 9, 2017

Copy link
Copy Markdown
Contributor

@mayagao, what’s left here?

@jmkiley jmkiley assigned jmkiley and unassigned mayagao Mar 24, 2017
@jmkiley
jmkiley force-pushed the user-location-dot branch 2 times, most recently from 876bb5a to c2bc39d Compare March 27, 2017 19:14
@jmkiley

jmkiley commented Mar 27, 2017 •

Copy link
Copy Markdown
Contributor

To do:

  • Add comments
  • Make gifs

@jmkiley
jmkiley force-pushed the user-location-dot branch 2 times, most recently from 3cbed75 to 6120402 Compare March 28, 2017 00:08
Comment thread Examples.xcodeproj/project.pbxproj Outdated
96D431FC1C84B4F7007D09D1 /* DrawingACustomMarkerExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 96D431FB1C84B4F7007D09D1 /* DrawingACustomMarkerExample.m */; };
96D432061C84B9CF007D09D1 /* pisavector.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96D432051C84B9CF007D09D1 /* pisavector.xcassets */; };
BBD05676206B24335DEA52C4 /* Pods_ExamplesUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7692D1D792EB3849E8754E6B /* Pods_ExamplesUITests.framework */; };
BBD05676206B24335DEA52C4 /* (null) in Frameworks */ = {isa = PBXBuildFile; };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This doesn’t seem right... 🤔

@jmkiley jmkiley modified the milestones: ios-v3.6.0, ios-v3.4.0 Mar 28, 2017
@friedbunny

friedbunny commented Mar 29, 2017 •

Copy link
Copy Markdown
Contributor

This PR has lost the ObjC implementation from #30 and instead has a mostly blank file at:

Examples/ObjectiveC/MBXExampleUserLocationAnnotation.swift

// Created by Nadia Barbosa on 12/13/16.
// Copyright © 2016 Mapbox. All rights reserved.
//

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This file seems misplaced.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it was missing from my version, not sure if it's needed. Can remove it if it's not necessary :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I’m guessing it’s not necessary — that file already exists in the Objective-C folder.

@jmkiley
jmkiley force-pushed the user-location-dot branch 4 times, most recently from 04ebf73 to b7db8b6 Compare April 21, 2017 18:04
@jmkiley

jmkiley commented Apr 23, 2017

Copy link
Copy Markdown
Contributor

I think this is ready for review. Added some comments to @mayagao's code!
img_5950

}

- (void)update {
// This method can be called many times a second, so be careful to keep it lightweight.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should explain more about the role/origin of -update. It’s inherited from MGLUserLocationAnnotationView and is essentially mandatory for every implementation.


// Rotate the arrow according to the user’s heading.
CGAffineTransform rotation = CGAffineTransformRotate(
CGAffineTransformIdentity,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let’s move the indentation left here.


// Create subclass of MGLUserLocationAnnotationView.
class CustomUserLocationAnnotationView: MGLUserLocationAnnotationView {
let size: CGFloat = 23

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ObjC has this set to 25 — let’s make it consistent (either way).

arrowSize = size / 2.5
arrow = CAShapeLayer()
arrow.path = arrowPath()
arrow.bounds = CGRect(x: 0, y: (size/2 + 2), width: arrowSize, height: arrowSize)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What does size/2 + 2 do here? In general, it’d be good to eliminate any inconsistencies between the ObjC and Swift implementations.

Sorry, I realize I wrote most of this.

arrow = CAShapeLayer()
arrow.path = arrowPath()
arrow.bounds = CGRect(x: 0, y: (size/2 + 2), width: arrowSize, height: arrowSize)
arrow.bounds = CGRect(x: 0, y: 0, width: arrowSize, height: arrowSize)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The arrow never appears after this change, because it has no position. Going back to a suggestion @1ec5 made long ago in #30 (comment), it would probably be better to set a frame (and not have to worry about bounds+position.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Updated in ccf36a5

@jmkiley

jmkiley commented May 9, 2017

Copy link
Copy Markdown
Contributor

Still running into issues with the Swift example. Also working on debugging an issue with the custom user location annotation being a little jerky when you pan the map view.
userlocationannotation

@jmkiley

jmkiley commented May 10, 2017

Copy link
Copy Markdown
Contributor

Noting that the above issue may be related to mapbox/mapbox-gl-native#8874

@jmkiley
jmkiley force-pushed the user-location-dot branch from 1a604fd to f8efda1 Compare June 14, 2017 01:06
@friedbunny

Copy link
Copy Markdown
Contributor

An interesting direction to take this example could be to introduce some variability into the styling — such as changing colors based on the map style.

/cc @fabian-guerra

@captainbarbosa

Copy link
Copy Markdown
Contributor

Anything moving on this?

@jmkiley

jmkiley commented Dec 12, 2017

Copy link
Copy Markdown
Contributor

Not right now. Need to redo it.

@friedbunny
friedbunny force-pushed the user-location-dot branch 2 times, most recently from 5d60096 to 971886f Compare December 13, 2017 22:39
@friedbunny

friedbunny commented Dec 13, 2017 •

Copy link
Copy Markdown
Contributor

I updated this branch and fixed the remaining issues.

  • Swift and ObjC both now work.
  • Heading rotation has been updated to more closely match MGLFaux3DUserLocationAnnotationView’s implementation.
  • Heading arrow has been simplified and moved into the dot.
  • Added hackish tap-on-user-dot-to-toggle-heading-tracking.

img_768eb3c72318-1

/cc @captainbarbosa @jmkiley

@jmkiley jmkiley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎉

@friedbunny

Copy link
Copy Markdown
Contributor

Squashed this but tried to preserve the version in #50 (comment) via 3a06ac8, which has the heading indicator placed on the outside and could be useful to reference sometime in the future.

@friedbunny friedbunny changed the title [Not ready] User location dot example User location dot example Dec 14, 2017
@friedbunny friedbunny self-assigned this Dec 14, 2017
@friedbunny friedbunny modified the milestones: ios-v3.6.0, ios-v3.7.0 Dec 14, 2017

@captainbarbosa captainbarbosa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

😍 yay!

@friedbunny
friedbunny merged commit 1b96d85 into master Dec 15, 2017
@friedbunny
friedbunny deleted the user-location-dot branch December 15, 2017 00:02
@friedbunny

Copy link
Copy Markdown
Contributor

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.

5 participants