vue3-maplibre-gl
Version:
Vue 3 components and composables for MapLibre GL JS - Build interactive maps with ease
50 lines (49 loc) • 1.92 kB
TypeScript
import { Nullable, ImageDatas } from '../../types';
import { MaybeRef } from 'vue';
import { Map, StyleImageMetadata } from 'maplibre-gl';
/**
* Image creation status enum for better state management
*/
export declare enum ImageStatus {
NotCreated = "not-created",
Loading = "loading",
Created = "created",
Updated = "updated",
Error = "error"
}
interface CreateImageProps {
map: MaybeRef<Nullable<Map>>;
id: string;
image: ImageDatas | string;
options?: Partial<StyleImageMetadata>;
debug?: boolean;
/**
* Force recreation when image dimensions change instead of throwing error.
* When true (default), images are always removed and re-added to prevent dimension mismatch errors.
* When false, uses the legacy behavior of trying updateImage first and falling back to recreation on error.
*/
forceRecreateOnDimensionChange?: boolean;
}
interface CreateImageActions {
remove: () => void;
loadImage: (imageUrl: string) => Promise<HTMLImageElement | ImageBitmap>;
updateImage: (newImage: ImageDatas | string) => Promise<void>;
refreshImage: () => Promise<void>;
hasImage: () => boolean;
imageStatus: Readonly<ImageStatus>;
isImageReady: boolean;
loadPromise: Promise<void>;
}
/**
* Composable for creating and managing MapLibre GL Images
* Provides reactive image management with error handling, performance optimizations, and enhanced API
*
* **Important:** MapLibre GL requires that updated images have the same dimensions as the previous version.
* This composable automatically handles dimension changes by removing and re-adding images when necessary.
*
* @param props - Configuration options for the image
* @returns Enhanced actions and state for the image
*/
export declare function useCreateImage(props: CreateImageProps): CreateImageActions;
export {};
//# sourceMappingURL=useCreateImage.d.ts.map