Skip to content
This repository has been archived by the owner on May 9, 2018. It is now read-only.

Random annotation layer position #137

Closed
alexiscreuzot opened this issue Oct 11, 2012 · 14 comments
Closed

Random annotation layer position #137

alexiscreuzot opened this issue Oct 11, 2012 · 14 comments
Labels

Comments

@alexiscreuzot
Copy link

I'm trying to display a set of RMMarker on top of an RMShape, but it seems like the layer ordering is broken/behaving weirdly :

weird behavior
(See how some markers are on top of the RMShape, and some under)

I think my issue can be related to this one, but it did not help.
I also tried fiddling with setZPosition:<#(CGFloat)#>, but the problem is still occurring.

@incanus
Copy link
Contributor

incanus commented Oct 11, 2012

So the SDK is automatically adjusting RMMarker ordering via zPosition from 1 to x where x is the number of markers total. I would suggest using negative values for your shapes. We do this with the user location-related annotation layers; however these are very large negative numbers so they should stay out of your way.

@alexiscreuzot
Copy link
Author

I already tried something like [annotation.layer setZPosition:-999];, but it's not working either...
Also when I log zPosition, it shows a zPosition of 0 for every annotations.

@tracyharton
Copy link
Contributor

could be the quadTree code which overwrites zPosition

@incanus
Copy link
Contributor

incanus commented Oct 16, 2012

So @kirualex the zPosition isn't sticking then? I wonder, are you recreating your layers frequently, or continuing to use the same ones? The zPosition should not get reset to zero by anything.

@dive
Copy link

dive commented Oct 25, 2012

Can confirm problem with zPosition. I'm trying to show layer with RMMarker and RMCircle with RMCircle zPosition set to -MAXFLOAT (try with other values, no chance), but RMCircle randomly showing on top of RMMarker. iOS SDK 6.0.

@dive
Copy link

dive commented Oct 25, 2012

as I can see, at RMMapView.m line 2530 your wrote

for (CGFloat i = 0; i < [sortedAnnotations count]; i++)
        ((RMAnnotation *)[sortedAnnotations objectAtIndex:i]).layer.zPosition = (CGFloat)i;

and before this you try to order array with annotation.position at line 2506. while ordering this code just ignore previous values of zPosition.

@dive
Copy link

dive commented Oct 26, 2012

so, if add some additional logic around zPosition assignment and store zPosition for layers with user defined values this issue gone

for (CGFloat i = 0; i < [sortedAnnotations count]; i++) {
        if (((RMAnnotation *)[sortedAnnotations objectAtIndex:i]).layer.zPosition == 0.0f) {
            ((RMAnnotation *)[sortedAnnotations objectAtIndex:i]).layer.zPosition = (CGFloat)i;
        }
    }

@incanus
Copy link
Contributor

incanus commented Oct 31, 2012

Ah, good catch. That might be a good patch, to manually-set zPosition. I'll have a look.

@incanus
Copy link
Contributor

incanus commented Nov 17, 2012

How is this behavior now? There is a reordering routine in there now that should be fixing this.

@alexiscreuzot
Copy link
Author

Well I'm now able to set the zPosition by myself but weirdly enough it's not influencing the display (I still have markers displayed randomly over or under my RMShape.
I'll have a deeper look this week though, as I just had a quick glance after updating the code (I was using my own fork with the tapEnabled property on annotations which I need).

@incanus
Copy link
Contributor

incanus commented Nov 20, 2012

@dive how is your implementation looking? Do you still need to apply your own fix?

@alexiscreuzot
Copy link
Author

Sorry, i'm totally hooked up on another project for now. Someone else
should join my team and have a look at it. I will point him to this thread
for any improvements on this matter !

Alexis

Le 20 nov. 2012 à 20:15, "Justin R. Miller" [email protected] a
écrit :

@dive https://github.com/dive how is your implementation looking? Do you
still need to apply your own fix?


Reply to this email directly or view it on
GitHubhttps://github.com//issues/137#issuecomment-10568502.

@weitzh
Copy link

weitzh commented Dec 5, 2012

In the cocoa pods version 0.5.0 I still have to apply Dive's line, just as info. Good work on the new version !

@incanus
Copy link
Contributor

incanus commented Dec 6, 2012

I think if you specify any custom zPosition, you will need to take this on yourself. I think this is probably best done with customizations to RMMapView directly in this fashion. The SDK is meant to manage this for you in correctOrderingOfAllAnnotations.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants