queryRenderedFeatures index incorrect
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
Hello
I have a question about queryRenderedFeatures features, If the two points exist on the tile split line respectively, there is a problem with the data level queried through queryRenderedFeatures 。
Like this :

52227 on top of 5226 ,whtn i click 52227 ,The first point returned is 52226

` // https://account.mapbox.com
mapboxgl.accessToken = 'pk.eyJ1IjoicTI0MzQwMDYiLCJhIjoiY2o2NTJkYjc2MXllaTJ3bzNjdGpjb3F0diJ9.vWycWIN3jBFVmTGHD5MhyA';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/light-v10',
center: [106.89142, 29.289455],
zoom: 18
});
map.showTileBoundaries = true
map.showCollisionBoxes = true
var ppts = [{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [106.891509, 29.289387]
},
"properties": {
"title": "52227"
}
}, {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [106.89142, 29.289455]
},
"properties": {
"title": "52226"
}
}]
map.on('click', 'points', (e) => {
alert(e.features[0].properties.title);
})
map.on('load', function () {
map.loadImage(
'https://docs.mapbox.com/mapbox-gl-js/assets/custom_marker.png',
function (error, image) {
if (error) throw error;
map.addImage('custom-marker', image);
map.addSource('points', {
'type': 'geojson',
'data': {
'type': 'FeatureCollection',
'features': ppts
}
});
map.addLayer({
'id': 'points',
'type': 'symbol',
'source': 'points',
'layout': {
'icon-image': 'custom-marker',
'icon-allow-overlap': true,
'icon-ignore-placement': true,
"icon-anchor": "bottom",
'text-allow-overlap': true,
'text-field': ['get', 'title'],
'text-font': [
'Open Sans Semibold',
'Arial Unicode MS Bold'
],
'text-offset': [3, 0]
}
});
}
);
});
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the queryRenderedFeatures entry point and reproduce the supplied map with the two points, the points layer, and the click handler. Investigate the returned feature order when points lie on a tile split line; done means the documented or intended hit-test result is consistent and covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100