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

User location puck for course tracking mode #2233

Closed
wants to merge 20 commits into from

Conversation

friedbunny
Copy link
Contributor

Adds a "puck" that replaces the user location dot when MGLUserLocationTrackingModeCourse is active.

  • Moves the current dot drawing code to -drawDot
  • Adds -drawPuck
  • Adds _puckModeActivated boolean
    • Used to reset the layers when switching between dot/puck
  • Draws a bezier arrow graphic for the puck in -puckArrow

There are still a variety of things to do:

  • Pitch the puck with CATransform3D
  • Code cleanup
  • Tweak visual style (shadow?)
  • Test with rotated/pitched camera
  • Add option to use the puck without MGLUserLocationTrackingModeCourse?
  • Update MGLMapView where necessary
  • Add transitions when switching between dot and puck

simulator screen shot sep 1 2015 11 06 05 pm

Fixes #2188.

/cc @incanus @1ec5 @mapbox/mobile

@friedbunny friedbunny added feature iOS Mapbox Maps SDK for iOS ⚠️ DO NOT MERGE Work in progress, proof of concept, or on hold labels Sep 2, 2015
@friedbunny friedbunny force-pushed the skate-to-where-the-puck-will-be branch from e6e8ed6 to 2205b2d Compare September 4, 2015 01:36
}
}

CGFloat MGLRadiansFromDegrees(CLLocationDegrees degrees)
Copy link
Contributor

Choose a reason for hiding this comment

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

These methods are also defined in MGLMapView.mm. Can you factor these implementations out into MGLGeometry.h?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, I'll do that.

@friedbunny
Copy link
Contributor Author

Tilting the map now also tilts the puck:

pitchedpuck

Also: rebased on master and toned down the shadow (a bit too much, as it turns out).

We explicitly don't tilt the user dot right now, but it actually looks pretty good, too:

dot

@friedbunny friedbunny force-pushed the skate-to-where-the-puck-will-be branch from baf647b to 2eba2ce Compare September 4, 2015 05:46
@friedbunny
Copy link
Contributor Author

I added pitch to the user dot.

Why?

  • The accuracy ring looks terrible unpitched on a tilted map
  • It was really simple to implement
  • It's cool and looks better, even if it diverges from Apple Maps

The pitched accuracy ring still has sizing issues: vertical screen movement isn't accounted for and all elements of the annotation (and puck) keep a constant scale, even though they shouldn't.

@1ec5
Copy link
Contributor

1ec5 commented Sep 4, 2015

I agree with tilting the accuracy ring, but tilting the dot itself looks odd unless we give it some thickness or elevation.

@friedbunny
Copy link
Contributor Author

screen shot 2015-09-04 at 1 46 08 pm

fake_depth

@incanus
Copy link
Contributor

incanus commented Sep 4, 2015

@1ec5 1ec5 assigned 1ec5 and friedbunny and unassigned 1ec5 Sep 4, 2015
@1ec5
Copy link
Contributor

1ec5 commented Sep 4, 2015

As of 17003db:

bubble

The user dot is now drawn twice: each instance of the dot is masked to show a semicircle, and only the lower semicircle is tilted, giving the illusion of a hemispherical bubble.

Back to @friedbunny for review.

@1ec5 1ec5 added ⚠️ DO NOT MERGE Work in progress, proof of concept, or on hold and removed ⚠️ DO NOT MERGE Work in progress, proof of concept, or on hold labels Sep 4, 2015
@friedbunny
Copy link
Contributor Author

My current thinking is that:

  1. Setting the transform property on many individual CALayers is too slow and introduces noticeable lag when you're using the tilt gesture.
  2. Go back to setting the parent CALayer.subLayerTransform and then retransform the dome layer to flat.
  3. ... but this adds flickering in the dot layer and the dome layer during the tilting gesture.
  4. So only allow the (animated) dome transform to happen after the tilting is over. WIP.

friedbunny and others added 11 commits September 8, 2015 11:43
Previously in #2265 we would ask for location permission at app startup if `!settings->showsUserLocation`. #2193 0a172a2 changed the way we used `NSUserDefaults` and mostly removed the `settings` object, which broke #2265.

Rather than fix our pestering location permissions ask at startup, this commit now only asks for location permissions when the user hits the locate-me button.

Once a user grants permission, the user dot appears because a `userTrackingMode` is set, `showsUserLocation` is permanently set to `YES` in `NSUserDefaults` and is restored at launch.
I'm not much of a hockey fan, but those playoff beards are pretty swell.
This exposes the naïveté of the current pitch transform: accuracy ring sizing stays constant, despite vertical screen movement. Still, it looks better pitched than not.
@friedbunny friedbunny force-pushed the skate-to-where-the-puck-will-be branch from f244254 to db4a836 Compare September 9, 2015 02:44
@friedbunny
Copy link
Contributor Author

Still fighting flickering during the tilt gesture, tracked it down to the animations. Now animations are paused and unpaused when the gesture starts/finishes.

Sadly, I'm considering ditching the 3D flying-saucer look and seeing if not pitching the dot (only the accuracy ring) is a viable option.

@friedbunny
Copy link
Contributor Author

The masking appears to be an issue here, too. If we were to only transform the inner dot (and not split it in two, then mask one side) that might improve the flickering.

@1ec5
Copy link
Contributor

1ec5 commented Sep 9, 2015

Instead of masking, maybe we could draw both halves of the dot as actual semicircles.

I couldn't get the dome to perform well and not flicker, so pour one out for the cool flying saucer that could have been.
@friedbunny
Copy link
Contributor Author

I think we're ready to go here. Next step is to rebase, squash, and get some eyes on this.

faker-depth

Ended up removing the dome and going with another faux 3D-ism by setting the zPosition for the inner dot to raise as the map is tilted. This skips the flickering and/or lag that I failed to eliminate from the dome implementation.

@1ec5
Copy link
Contributor

1ec5 commented Sep 10, 2015

If we ever allow pitching beyond 60°, we’ll have to revisit this approach and probably figure out how to make the dome work, but this looks great as-is.

@friedbunny
Copy link
Contributor Author

screen shot 2015-09-10 at 2 06 07 pm

@friedbunny
Copy link
Contributor Author

Squashed over in #2300. Thanks for the memories, #2233.

@friedbunny friedbunny closed this Sep 10, 2015
@friedbunny friedbunny deleted the skate-to-where-the-puck-will-be branch September 10, 2015 20:17
@1ec5 1ec5 removed the ⚠️ DO NOT MERGE Work in progress, proof of concept, or on hold label Nov 9, 2015
@1ec5 1ec5 mentioned this pull request Dec 4, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants