UNPKG

@mapbox/mapbox-gl-draw

Version:

A drawing component for Mapbox GL JS

15 lines (13 loc) 429 B
/** * Returns a bounding box representing the event's location. * * @param {Event} mapEvent - Mapbox GL JS map event, with a point properties. * @return {Array<Array<number>>} Bounding box. */ function mapEventToBoundingBox(mapEvent, buffer = 0) { return [ [mapEvent.point.x - buffer, mapEvent.point.y - buffer], [mapEvent.point.x + buffer, mapEvent.point.y + buffer] ]; } export default mapEventToBoundingBox;