UNPKG

431 BJavaScriptView Raw
1/**
2 * Returns a bounding box representing the event's location.
3 *
4 * @param {Event} mapEvent - Mapbox GL JS map event, with a point properties.
5 * @return {Array<Array<number>>} Bounding box.
6 */
7function mapEventToBoundingBox(mapEvent, buffer = 0) {
8 return [
9 [mapEvent.point.x - buffer, mapEvent.point.y - buffer],
10 [mapEvent.point.x + buffer, mapEvent.point.y + buffer]
11 ];
12}
13
14module.exports = mapEventToBoundingBox;