A utility function that calculates the true viewport bounds of a Mapbox GL map instance, ignoring any padding that might be set on the map. This is particularly useful when you need to work with the actual visible area of the map without padding adjustments.
<script setup lang="ts">
import { mapboxGetActualMapBounds } from '@nobears-front-end/nuxt-mapbox';
const map = new mapboxgl.Map({ ... });
const bounds = mapboxGetActualMapBounds(map, 50);
console.log(bounds); // [-180, -85, 180, 85] or actual bounds if map exists
</script>
declare type MapboxMapBounds = [number, number, number, number];
const DEFAULT_WORLD_BOUNDS: MapboxMapBounds = [-180, -85, 180, 85] as const;
declare function mapboxGetActualMapBounds(
map: Map | null,
padding?: number
): MapboxMapBounds;
Calculates the actual map bounds ignoring any padding set on the map.
0