mapbox / mapbox/mapbox-gl-js

CollisionArrays.iconBox is not updated correctly for symbols at higher zoom levels (therefore queryRenderedFeatures is failing)

Open
#10,037 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs investigation :mag:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

I've a vector tile source that contain point feature from (z2 to z6).
A symbol layer is representing the point's from the above source. `point-zips`

I was trying to retrieve features based on pointer event using `queryRenderedFeatures(e.point)`

this method is resolving the point features correctly till map z < 14.
when z >= 14 the symbol point's are not selectable.

from what understood so far
1) with any map interaction, all symbols in viewport have their collisionArrays updated
2) for the fiddle below z14 all `point-zips` has collisionArrays.iconBox as [x1,y1,x2,y2] and above it is [0,0,0,0]
3) based on the collisionArrays in (2) I think grid bboxes are [calculated](https://github.com/mapbox/mapbox-gl-js/blob/12991995fa1bb62c5ecdb0282c7c142578b897e5/src/symbol/collision_index.js#L69) being [set](https://github.com/mapbox/mapbox-gl-js/blob/12991995fa1bb62c5ecdb0282c7c142578b897e5/src/symbol/grid_index.js#L63)
4) queryRenderedFeatures method after evaluating non symbol features tries to evaluate symbol feautures.
5) I think [here](https://github.com/mapbox/mapbox-gl-js/blob/12991995fa1bb62c5ecdb0282c7c142578b897e5/src/symbol/grid_index.js#L176) it is selecting the symbol as valid if the point in argument's is present inside the bbox generated from (3)
6) In a working scenario a valid bbox will be created as (2) gives distinct [x1,y1,x2,y2].In an invalid scenario bbox is created as a point [x1,y1,x1,y1] as (2) gives all zero's, thereby (5) will never return true for a point to be inside another point
7) I couldn't find how collisionArrays.iconBox is being computed

**mapbox-gl-js version**:
1.3.0

**browser**:
chrome: latest

### Steps to Trigger Behavior

1. the fiddle included has a zipcode source, styled to show points with airport-11
2. click on any symbol below 14 will print the layer id
3. after z14 it will never print layer id
4. this behaviour is not observed if the source is geojson (which works for all zoom levels)
5. change in feature icon-size will change z from where it fails
6. all other symbols on the map will print their id at all zoom levels as mapbox source maxzoom is 16

### Link to Demonstration
https://jsfiddle.net/gandhiamar2/182oms4f/21/

### Expected Behavior
queryRenderedFeatures should return features (symbol) at any zoom level irrespective of icon-size or tile maxzoom

### Actual Behavior
queryRenderedFeatures will fail to work based on vector tile's maxzoom and icon-size

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked JSFiddle reproduction and trace queryRenderedFeatures for symbol features. Inspect src/symbol/collision_index.js around line 69 and src/symbol/grid_index.js around lines 63 and 176, focusing on how CollisionArrays.iconBox changes at higher zoom levels. Done means the vector-tile symbols remain selectable with queryRenderedFeatures across the reported zoom levels and icon sizes.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.