[6.7] [Maps] add some padding around mouse pointer (#33415) (#33452) (#33527)

This is not a clean backport due to the implementation diverging in 7.x/master vs 7.0/6.7. It requires adding a tooltip-listener to the border layer.
This commit is contained in:
Thomas Neirynck 2019-03-19 15:18:25 -04:00 committed by GitHub
parent 894167a256
commit 4d234f8d3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -475,6 +475,7 @@ export class VectorLayer extends AbstractLayer {
mbMap.setLayoutProperty(lineLayerId, 'visibility', this.isVisible() ? 'visible' : 'none');
mbMap.setLayerZoomRange(lineLayerId, this._descriptor.minZoom, this._descriptor.maxZoom);
mbMap.setLayerZoomRange(fillLayerId, this._descriptor.minZoom, this._descriptor.maxZoom);
this._addTooltipListeners(mbMap, lineLayerId);
this._addTooltipListeners(mbMap, fillLayerId);
}
@ -569,7 +570,18 @@ export class VectorLayer extends AbstractLayer {
return;
}
const features = mbMap.queryRenderedFeatures(e.point)
const PADDING = 2;//in pixels
const mbBbox = [
{
x: e.point.x - PADDING,
y: e.point.y - PADDING
},
{
x: e.point.x + PADDING,
y: e.point.y + PADDING
}
];
const features = mbMap.queryRenderedFeatures(mbBbox)
.filter(feature => {
return feature.layer.source === this.getId();
});