Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

z-index issues #63

Open
DerDakon opened this issue Mar 31, 2016 · 2 comments
Open

z-index issues #63

DerDakon opened this issue Mar 31, 2016 · 2 comments

Comments

@DerDakon
Copy link
Collaborator

There are at least 2 z-index issues, which probably need a combined solution, so I report them in one issue:

  • together with allow-overlap z-index is actually reversed as the objects are drawn in decreasing z-index order, and if allow-overlap is set the later object is drawn above the previous one (which has a higher z-index). This cannot be fixed using "globalCompositeOperation='source-over'" as this would draw the new object below everything on the canvas, i.e. also those objects with lower z-index (e.g. geometry). An example of the error can be seen on OpenRailwayMap, the z-index of the white signs corresponds to the number shown on it.
  • the code to render text and icons does one pass through one text/icon combination before rendering the next (see kothic.js), which means a bare icon with low z-index would be drawn first, and a bare text with high z-index would not be drawn at all if it collides with this icon.
@braandl
Copy link
Contributor

braandl commented May 10, 2016

styledFeatures.sort(function (a, b) { return a.zIndex < b.zIndex ? -1 : a.zIndex > b.zIndex ? 1 : 0; });

does fix the z-index problems. I don't understand why it was comparing the fill-color and color keys?

@DerDakon
Copy link
Collaborator Author

This could have been written even simpler as return a.zIndex - b.zIndex. But this does not solve the problem, as the sorting already works. It's the algorithm in which order things are drawn and how it interacts with "allow-overlap: true".

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

No branches or pull requests

2 participants