mapbox / mapbox/mapbox-gl-js

queryRenderedFeatures index incorrect

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

Nobody has claimed this yet.

bug :lady_beetle:
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 :
![image](https://user-images.githubusercontent.com/12470760/97954717-45bf2780-1ddf-11eb-8c38-b350867d12c3.png)
52227 on top of 5226 ,whtn i click 52227 ,The first point returned is 52226
![image](https://user-images.githubusercontent.com/12470760/97954938-ced65e80-1ddf-11eb-9863-195c38432655.png)
` // 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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.