Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Marker draw order #31

Closed
russellquinn opened this Issue · 21 comments

4 participants

Russell Quinn Justin R. Miller cwir8 Ignacio Romero Zurbuchen
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
Admin

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
Admin

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
Closed

Location annotation zIndex #6

Justin R. Miller
Admin

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
Admin

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
Admin

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
Admin
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
Justin R. Miller incanus 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
Admin

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.

Justin R. Miller incanus closed this
cwir8

HI !
@incanus any news about this bug ? In my app i have something like focusing on particular annotation and i can't find a way to bring it to front if there are another annotations above. Any ideas ?

Justin R. Miller
Admin

The basic subject of this ticket was fixed a while back, but what you are talking about @cwir8 is more like #160 I think. No progress on that right now, though if you [mapView selectAnnotation:], it should always be brought to the front.

cwir8

i tried a while ago but no luck. Now i found that i set annotation.enabled to NO and that was the reason . Now i deleted that line and its working !

Ignacio Romero Zurbuchen

What happen with orderClusterMarkersAboveOthers flag? Would be useful to get deprecated attributes, instead of missing ones. Updating old projects using this framework gets really hard. Many stuff have changed since last year, and many are just not there anymore.

Justin R. Miller
Admin

You're right @dzenbot, let me get a point release out that does a better job with that.

Justin R. Miller
Admin

@dzenbot Does 67b0cb8 look like a better approach?

Ignacio Romero Zurbuchen

That's just perfect! Thanks a lot

Justin R. Miller
Admin

Rolled into 1.4.1.

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.