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

annotations plan #877

Closed
Closed

Description

@incanus

"Annotations" is iOS-speak for points and polygons on the basemap with a high-level client-side API.

  • Data — This encapsulates such things as client-side data (client-side data #507) or formats like GeoJSON, and also includes programmatic addition of points and polygons that don't exist in files or formats at all (e.g. show user location, add these stores to the map, trace this route from parsed directions API). In fact, format-less features are the MVP for this. Spatial indexing falls under this category as well — the system needs to know what's on screen right now as well as be able to translate between pixel-space and geo-space (fixes #476: pixel / projected meter / lat/long conversions #853).
  • Design — Polylines & polygons can get styling properties like width, fill color, opacity, and stroke color. This can change at runtime, so it's not part of the GL style. Markers can get a) static marker imagery, b) iOS UIView objects, or even c) animations of views. These can also all change / be provided at runtime. Markers always remain upright when the map rotates and order themselves in the z-axis from current top-to-bottom of screen, updating continuously as the map rotates. Lastly, marker annotations have callouts, which should be implemented specific to iOS (likely using SMCalloutView as our SDK does).
  • Interaction — Users can tap on poly & marker visuals and get callbacks with the associated data object referenced.
  • API — All APIs follow Apple's MapKit, so relevant classes & protocols are MKMapView, MKAnnotation, MKAnnotationView, and MKMapViewDelegate.
    • An MKAnnotation-derived data object is added (map.addAnnotation(foo)) .
    • An MKMapViewDelegate is set on a map (map.delegate = bar).
    • When the visual for an annotation is relevant/on screen, a view is requested from the delegate, which creates it on the fly (func mapView(map, viewForAnnotation: foo)).
    • The map maintains and responds to annotation selection state (func mapView(map, didSelectAnnotation:foo))

Will kick off deeper tickets for each of these buildouts as we progress.

Activity

  1. added
    iOS
    on Feb 13, 2015
  2. added this to the milestone on Feb 13, 2015
  3. incanus commented on Feb 16, 2015

    @incanus
    ContributorAuthor

    Conversion routines are in and API for mocking annotations atop the GL view is available.

    Next steps are @ljbade & @bleege checking out #756 on Android and I will start mocking markers (not spatially indexed, however, to start) to see how the FPS handles the compositing.

  4. incanus commented on Feb 17, 2015

    @incanus
    ContributorAuthor

    @kkaefer Here's a small sample project that does animated point markers and animated polygon rendering as an example of what an iOS developer might expect.

    Video demo: https://dl.dropboxusercontent.com/u/575564/animatedannotations.mp4

    screen shot 2015-02-16 at 5 57 57 pm

    Markers

    The ViewController delegates to the PointAnnotationView class, which uses Core Animation to rotate itself over time (keyframe animations over a few seconds) and a repeating timer to alter its background color, alpha, and border thickness (eight or so animation steps). You could typically see something like this for a game or interactive app which uses keyframe animations at points on the map (animated oil wells or realtime pie charts, for example).

    Polylines

    The ViewController also delegates to the AnimatedRenderer class, which uses a timer to change the size of an image that is used as a tiled pattern fill color every few seconds. This is a bit of a contrived example, but you might do an animated radar overlay or a moving pattern animation to indicate flow across a map surface.

    The point is less about flashiness and more about the fact that an iOS dev will expect to author views and renderers as first-class Cocoa objects for the control of animations, colors, strokes, patterns, opacities, and timing.

  5. incanus commented on Feb 17, 2015

    @incanus
    ContributorAuthor

    Per voice with @1ec5, it might make sense to not necessarily adopt an either-or (core vs. per-platform) approach. For example, simple sprite-based markers (Maki or otherwise) could be done in the icon shader, but more complex views could be composited and tracked to the map per-platform.

    Of note in the simple use case is the fact that z-ordering matters; markers are ordered back-to-front (z) by order of top-to-bottom (y), including changing on the fly during map rotations. On iOS, when selected, a marker comes all the way to the front temporarily, then goes back in place on deselect.

  6. 1ec5 commented on Feb 17, 2015

    @1ec5
    Contributor

    For example, simple sprite-based markers (Maki or otherwise) could be done in the icon shader, but more complex views could be composited and tracked to the map per-platform.

    And ideally the heuristic would be on our end, not something the dev has to think about.

  7. mb12 commented on Feb 17, 2015

    @mb12

    @incanus and @kkaefer Is it possible to share how you would synchronize between iOS UIView and GLViews. Otherwise there would always be a lag between overlay UIView (e.g. Bubble) and underlying MGLMapView. Specifically this is the problem I am referring it.

    http://stackoverflow.com/questions/12967340/how-to-synchronize-opengl-drawing-with-uikit-updates

  8. incanus commented on Feb 17, 2015

    @incanus
    ContributorAuthor

    Is it possible to share how you would synchronize between iOS UIView and GLViews

    I've had good luck using CADisplayLink for this in some old tests.

    https://github.com/incanus/FeaturesPlay

    http://www.mobypicture.com/user/incanus771/view/17359491

    I'm trying this again now in this project currently.

  9. incanus commented on Feb 17, 2015

    @incanus
    ContributorAuthor

    @1ec5 I pushed what I've been playing with at 877-display-link branch.

  10. incanus commented on Feb 17, 2015

    @incanus
    ContributorAuthor

    Per voice with @1ec5 @kkaefer, we decided the beta will not support full UIView objects passed by the delegate as annotation views, but rather only static imagery at this point.

    MapKit's delegate API, which we will model after, looks like this:

    - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation

    When an annotation view is requested, you would return an MKAnnotationView or its subclass MKPinAnnotationView, which are all subclasses of UIView.

    What we can do as a first step is to only support an MKPinAnnotationView-like class which either:

    • Refers to known parameters such as Maki icon, color, or size (similar to MKPinAnnotationView.pinColor) and keys those to GL core routines to render those with the icon shader, or
    • Accepts user-provided imagery which we pass across the boundary to the icon shader.
  11. mb12 commented on Feb 18, 2015

    @mb12

    Is it possible to make the pins draggable for iOS?

  12. incanus commented on Feb 18, 2015

    @incanus
    ContributorAuthor

    I'm not sure yet if we'll hit that for the beta, but eventually, yes.

  13. added 2 commits that reference this issue on Feb 18, 2015
  14. 45 remaining items

  15. incanus commented on Mar 4, 2015

    @incanus
    ContributorAuthor

    Sweet! This is great. Runs well for me, too. What is there to merge just yet, though @bleege? The actual driver of where the annotations should track to is coming in #893 and we have yet to architect what the annotation view classes look like, though they likely will be UIImageView like here, since we're only supporting Maki and user-inputted imagery (see #941).

  16. bleege commented on Mar 4, 2015

    @bleege
    Contributor

    Awesome! Thanks for testing it out @incanus.

    As for what to merge the most important part is MGLMapView.h and MGLMapView.mm from 4ea6b25 where the GLKView is made accessible. That said maybe the easiest way to get it in there would be to just cherrypick those files?

  17. incanus commented on Mar 4, 2015

    @incanus
    ContributorAuthor

    Ew, I think exposing the GLKView is confusing from a public API point of view. We should probably think about a class extension that's private that our own APIs can get to, as opposed to putting that in MGLMapView.h.

  18. incanus commented on Mar 4, 2015

    @incanus
    ContributorAuthor

    Or when we build out our actual annotation-adding API in Cocoa, it creates the subviews and adds them to the GLKView itself. The fact that this is in the view controller is an implementation detail right now, but consumers of our API need to be able to just run with MGLMapView and nothing else in their app.

  19. bleege commented on Mar 4, 2015

    @bleege
    Contributor

    Totally makes sense... I just had put it there more for expediency purposes when I was experimenting earlier today. Maybe the best thing to do is just leave this branch as is and just use it to guide #893 and #941?

  20. incanus commented on Mar 4, 2015

    @incanus
    ContributorAuthor

    Yeah, that's kinda what I had in mind with the "what to merge" above. We figured out how we're going to do it technically, but let's get some other pieces into place first.

    I see next steps in this department as:

    1. Make a call on allow for user-provided symbol imagery (aka Sprites) #941 for the beta, or just Maki imagery / annotation marker imagery prebuilt into the style(s).
    2. Get merge GeoJSON vector tiles work #893 to land, providing API to say where annotations are at any given point.
    3. Write live annotation C++ API.
    4. Wrap API in MapKit-like Cocoa goodness.
  21. incanus commented on Mar 11, 2015

    @incanus
    ContributorAuthor

    Markers always remain upright when the map rotates and order themselves in the z-axis from current top-to-bottom of screen, updating continuously as the map rotates.

    We've got a ticket for this over in JS in mapbox/mapbox-gl-js#470 but it seems to still be an issue:

    screen shot 2015-03-11 at 1 48 02 pm

    @kkaefer @ansis @jfirebaugh Any sense of how much work would be involved with this? We will likely also want the ability to temporarily bring a marker to the front upon selection.

    /cc @1ec5

  22. jfirebaugh commented on Mar 12, 2015

    @jfirebaugh
    Contributor

    Seem like it's time to unbundle this into separate followup tickets and close here.

  23. incanus commented on Mar 12, 2015

    @incanus
    ContributorAuthor

    Yep, agree. I will ticket some off now.

  24. incanus commented on Mar 12, 2015

    @incanus
    ContributorAuthor

    Thus far Cocoa API is meant to work like Apple's, but we may modify that as @1ec5 and I discuss integration steps.

  25. maciekish commented on Mar 24, 2015

    @maciekish
    Contributor

    @incanus Is it possible to draw routes in the current version? We are using an RMAnnotation with an array of CLLocations at the moment (in mapbox-ios).

  26. incanus commented on Mar 24, 2015

    @incanus
    ContributorAuthor

    No, routes are coming later. Just points for now. Watch #893.

  27. picciano commented on May 13, 2015

    @picciano

    @incanus Any update on the work to support routes (polylines) now that Beta 1 is about wrapped up? This is our single biggest need right now and I would very much appreciate your thoughts on possible timing.

  28. incanus commented on May 13, 2015

    @incanus
    ContributorAuthor

    @picciano Shape annotations are one of the major focuses for b2. We'll have better timelines shortly, but we are thinking on the order of weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureiOS

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions