Avoid false positives for line and polygon hit detection
This commit is contained in:
@@ -344,11 +344,13 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
|
|||||||
let i, ii;
|
let i, ii;
|
||||||
for (i = 0, ii = renderedTiles.length; i < ii; ++i) {
|
for (i = 0, ii = renderedTiles.length; i < ii; ++i) {
|
||||||
const tile = renderedTiles[i];
|
const tile = renderedTiles[i];
|
||||||
|
const tileExtent = tileGrid.getTileCoordExtent(tile.wrappedTileCoord);
|
||||||
|
const tileContainsCoordinate = containsCoordinate(tileExtent, coordinate);
|
||||||
|
|
||||||
if (!declutter) {
|
if (!declutter) {
|
||||||
// When not decluttering, we only need to consider the tile that contains the given
|
// When not decluttering, we only need to consider the tile that contains the given
|
||||||
// coordinate, because each feature will be rendered for each tile that contains it.
|
// coordinate, because each feature will be rendered for each tile that contains it.
|
||||||
const tileExtent = tileGrid.getTileCoordExtent(tile.wrappedTileCoord);
|
if (!tileContainsCoordinate) {
|
||||||
if (!containsCoordinate(tileExtent, coordinate)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -361,13 +363,15 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
|
|||||||
* @return {?} Callback result.
|
* @return {?} Callback result.
|
||||||
*/
|
*/
|
||||||
function(feature) {
|
function(feature) {
|
||||||
let key = feature.getId();
|
if (tileContainsCoordinate || (declutteredFeatures && declutteredFeatures.indexOf(feature) !== -1)) {
|
||||||
if (key === undefined) {
|
let key = feature.getId();
|
||||||
key = getUid(feature);
|
if (key === undefined) {
|
||||||
}
|
key = getUid(feature);
|
||||||
if (!(key in features)) {
|
}
|
||||||
features[key] = true;
|
if (!(key in features)) {
|
||||||
return callback(feature, layer);
|
features[key] = true;
|
||||||
|
return callback(feature, layer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, layer.getDeclutter() ? declutteredFeatures : null);
|
}, layer.getDeclutter() ? declutteredFeatures : null);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user