You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
"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.
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.
@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.
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 ViewControlleralso 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.
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.
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.
@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.
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:
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.
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).
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?
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.
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.
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?
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.
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:
@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.
@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).
@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.
Activity
incanus commentedon Feb 16, 2015
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.
incanus commentedon Feb 17, 2015
@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
Markers
The
ViewControllerdelegates to thePointAnnotationViewclass, 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
ViewControlleralso delegates to theAnimatedRendererclass, 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.
incanus commentedon Feb 17, 2015
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.1ec5 commentedon Feb 17, 2015
And ideally the heuristic would be on our end, not something the dev has to think about.
mb12 commentedon Feb 17, 2015
@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
incanus commentedon Feb 17, 2015
I've had good luck using
CADisplayLinkfor 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.
incanus commentedon Feb 17, 2015
@1ec5 I pushed what I've been playing with at
877-display-linkbranch.incanus commentedon Feb 17, 2015
Per voice with @1ec5 @kkaefer, we decided the beta will not support full
UIViewobjects 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>)annotationWhen an annotation view is requested, you would return an
MKAnnotationViewor its subclassMKPinAnnotationView, which are all subclasses ofUIView.What we can do as a first step is to only support an
MKPinAnnotationView-like class which either:MKPinAnnotationView.pinColor) and keys those to GL core routines to render those with the icon shader, ormb12 commentedon Feb 18, 2015
Is it possible to make the pins draggable for iOS?
incanus commentedon Feb 18, 2015
I'm not sure yet if we'll hit that for the beta, but eventually, yes.
#877 - Implementing MGLMapViewDelegate to enable debugging while addi…
#877 - Adding mapViewRegionIsChanging delegate method to MGLMapViewDe…
45 remaining items
incanus commentedon Mar 4, 2015
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
UIImageViewlike here, since we're only supporting Maki and user-inputted imagery (see #941).bleege commentedon Mar 4, 2015
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?
incanus commentedon Mar 4, 2015
Ew, I think exposing the
GLKViewis 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 inMGLMapView.h.incanus commentedon Mar 4, 2015
Or when we build out our actual annotation-adding API in Cocoa, it creates the subviews and adds them to the
GLKViewitself. 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 withMGLMapViewand nothing else in their app.bleege commentedon Mar 4, 2015
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?
incanus commentedon Mar 4, 2015
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:
incanus commentedon Mar 11, 2015
We've got a ticket for this over in JS in mapbox/mapbox-gl-js#470 but it seems to still be an issue:
@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
jfirebaugh commentedon Mar 12, 2015
Seem like it's time to unbundle this into separate followup tickets and close here.
incanus commentedon Mar 12, 2015
Yep, agree. I will ticket some off now.
incanus commentedon Mar 12, 2015
Thus far Cocoa API is meant to work like Apple's, but we may modify that as @1ec5 and I discuss integration steps.
maciekish commentedon Mar 24, 2015
@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).
incanus commentedon Mar 24, 2015
No, routes are coming later. Just points for now. Watch #893.
picciano commentedon May 13, 2015
@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.
incanus commentedon May 13, 2015
@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.