Skip to content
This repository

Marker draw order #31

Closed
russellquinn opened this Issue May 23, 2012 · 13 comments

2 participants

Russell Quinn Justin R. Miller
Russell Quinn

Should the markers be drawn in latitude order, so that they are positioned correctly?

See this screenshot for what I mean:

http://dl.dropbox.com/u/44154592/markerDrawOrder.png

I'm not sure how this would work in orientation (compass) mode in the Location branch, layer positioning would need to update as the map rotates maybe? :-/

Justin R. Miller
Owner
incanus commented May 23, 2012

Oof, hadn't thought of the rotation + annotations.

Otherwise, there's no real support for layer ordering yet. Each marker, as a CALayer subclass, however, has a zPosition and that can be used. I'm currently using it in a project to allow drag-reordering in a layer UI that iterates and updates these properties after the drag.

Clearly, an area that could be worked on.

Russell Quinn

I fixed the normal rendering by just sorting into latitude order before adding, but, yeah, rotating might a big headache :-/

Justin R. Miller
Owner
incanus commented May 30, 2012

I've yet to test, but I imagine MapKit auto-rotates the markers as the map rotates to keep them upright. This may not be as difficult as it first sounds, though, based on this:

- (void)setTransformAccordingToMapView:(MKMapView *)mapView {
    [self setTransform:CGAffineTransformInvert(mapView.transform)];
}
Russell Quinn

Hm, interesting. I'll check.

Another side note: annotation labels also don't get the correct z-index. They're often behind other markers. This should all be handled automatically, really, rather than relying on the app to juggle z-indexes?

Russell Quinn

These z-index issues are still present. The annotation markers are not drawn in latitude order (pre-ordering them helps, but there are still plenty in the wrong z-index order), so they overlap oddly.

Justin R. Miller incanus referenced this issue in mapbox/mapbox-me August 07, 2012
Closed

Location annotation zIndex #6

Justin R. Miller
Owner

Note that when we address this, we need to take into account the static location/heading imagery used that are not really annotation layers. They should draw below annotations but above the tracking halo.

Russell Quinn

Yep, the location annotations's z-positions vary all the time, and draw wherever they feel like! Aside from being aesthetically annoying, sometimes the dot draws right over a regular annotation, and then you can't tap it.

Justin R. Miller
Owner

Ok, I will take a crack at this for 0.4.0, but if it proves too difficult, I may push it off for now.

Justin R. Miller
Owner

Ok, general annotation ordering is now handled above. This includes during rotations. It wasn't actually too tricky, given that each RMAnnotation has a position and we can just use those instead of actual latitude to determine top-to-bottom ordering. Then, during rotation, this can be translated to the RMMapView frame of reference (which doesn't have to care that they are rotated) and still ordered top-to-bottom.

Let me know what you think.

The proper handling of the location dot when rotating still needs to be handled, though.

Russell Quinn

This seems to work well, though the rotation judders a lot now.

One possible issue is that single annotations can now be drawn over the top of clustered animation layers. I guess it's subjective what order they should be in, but my feeling is that the clustered layers should take priority.

In my previous hack to set the zPositions, I set two distinct zPosition ranges, one for regular annotations and one for clustered annotations. Thoughts?

Justin R. Miller
Owner
Russell Quinn

The other subtly with this is that if we fix it so that clustered annotations are always drawn above non-clustered annotations, then pop-up labels for non-clustered annotations can be drawn under clustered annotations. This probably feeds into the text-blurriness/proper-support-for-call-outs problem.

Justin R. Miller incanus referenced this issue from a commit August 16, 2012
Justin R. Miller refs #31: properly underlay user location stuff when tracking heading
 * move halo/circle annotations to ivars
 * recreate tracking halo outside of annotation system
 * properly order subviews/sublayers
156e9c8
Justin R. Miller incanus closed this August 16, 2012
Justin R. Miller
Owner

Ok, fixed the tracking dot layering when in heading mode, made clusters order below all other annotations, and added a BOOL called orderClusterMarkersAboveOthers to reverse this behavior. I like the default better ;-)

Gonna close; feel free to reopen if there are issues aside from #84 rotation jumpiness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.