-
-
Notifications
You must be signed in to change notification settings - Fork 789
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
Fix Circle Layer hitbox in Globe projection mode #5599
base: main
Are you sure you want to change the base?
Conversation
@@ -75,10 +76,11 @@ function getPixelPosMatrix(transform, tileID: OverscaledTileID) { | |||
const t = mat4.create(); | |||
mat4.translate(t, t, [1, 1, 0]); | |||
mat4.scale(t, t, [transform.width * 0.5, transform.height * 0.5, 1]); | |||
if (transform.calculatePosMatrix) { // Globe: TODO: remove this hack once queryRendererFeatures supports globe properly | |||
if ('calculatePosMatrix' in transform) { // Globe: TODO: remove this hack once queryRendererFeatures supports globe properly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have pixel to tile units support both mercator and globe and remove this if statement and todo?
When I looked at this feature I saw that the offset code is also broken. |
Thanks for the review! I’ll look into whether circle-offset works on the glove projection, write a quick blurb on what it’d take to fully resolve the TODO comment, and get back to you early next week. |
This PR fixes #5255 where circle layers have extremely small hitboxes when using the "globe" projection at low zoom levels.
Problem
When using Circle layers in the "globe" projection,
queryRenderedFeatures
only works over tiny fraction of the circle rather than the entire rendered feature. This makes interactive maps with circle layers frustrating to use at low zoom levels.Root Cause
The issue stems from the
pixelPosMatrix
calculation inqueryRenderedFeatures
. The implementation wasn't properly handling globe projection, leading to incorrect hit testing calculations inCircleStyleLayer#queryIntersectsFeature
.Solution
This PR updates the
getPixelPosMatrix
function inquery_features.ts
to account for the proper scale transformation when mapping between screen space and tile units. Deeper architectural changes are needed to say thatqueryRenderedFeatures
fully supports theglobe
projection but this addresses the immediate bug with a minimally intrusive fix.Testing
This should make Circle layers properly interactive in all projection modes.
Launch Checklist
Include before/after visuals or gifs if this PR includes visual changes.Document any changes to public APIs.Post benchmark scores.These should not change as a resultCHANGELOG.md
under the## main
section.