mapboxFocusFeatures() is a utility that helps focus the map view on one or more GeoJSON features.
Behavior for a single feature:
This is a fallback behavior. For a better zoom level, use mapboxFocusSingleFeature.
map.flyTo() to center the map on the feature's coordinatesBehavior for multiple features:
This is the intended behavior.
map.fitBounds()<script setup lang="ts">
import { mapboxFocusFeatures } from '@nobears-front-end/nuxt-mapbox';
// Focus on a single feature
mapboxFocusFeatures(map, [singleFeature], { duration: 1000 });
// Focus on multiple features
mapboxFocusFeatures(map, [feature1, feature2], { duration: 1000 });
</script>
declare function mapboxFocusFeatures(
map: Map | null,
features: MapboxFeatures,
options?: EasingOptions,
): void;