vue3-maplibre-gl
Version:
Vue 3 components and composables for MapLibre GL JS - Build interactive maps with ease
61 lines (60 loc) • 2.18 kB
TypeScript
import { Marker, Alignment, LngLatLike, Map, MarkerOptions, Popup, PointLike } from 'maplibre-gl';
import { Nullable } from '../../types';
import { MaybeRef, Ref } from 'vue';
/**
* Marker creation status enum for better state management
*/
export declare enum MarkerStatus {
NotCreated = "not-created",
Creating = "creating",
Created = "created",
Error = "error",
Removed = "removed"
}
interface MarkerEventHandlers {
dragstart?: (e: Event) => void;
drag?: (e: Event) => void;
dragend?: (e: Event) => void;
}
interface CreateMarkerProps {
map: MaybeRef<Nullable<Map>>;
lnglat?: MaybeRef<LngLatLike | undefined>;
popup?: MaybeRef<Nullable<Popup>>;
el?: Ref<HTMLElement | undefined>;
options?: MarkerOptions;
on?: MarkerEventHandlers;
debug?: boolean;
autoAdd?: boolean;
}
interface CreateMarkerActions {
marker: Readonly<Nullable<Marker>>;
markerStatus: Readonly<MarkerStatus>;
isMarkerCreated: boolean;
setLngLat: (lnglat: LngLatLike) => void;
setPopup: (popup?: Popup | null) => void;
setOffset: (offset: PointLike) => void;
setDraggable: (draggable: boolean) => void;
togglePopup: () => void;
getElement: () => HTMLElement | null;
setRotation: (rotation: number) => void;
setRotationAlignment: (alignment: Alignment) => void;
setPitchAlignment: (alignment: Alignment) => void;
setOpacity: (opacity: string, opacityWhenCovered?: string) => void;
removeMarker: () => void;
addMarker: () => void;
getLngLat: () => LngLatLike | null;
getPopup: () => Popup | null;
getOffset: () => PointLike;
getDraggable: () => boolean;
getRotation: () => number;
}
/**
* Composable for managing MapLibre GL Markers
* Provides reactive marker with error handling, performance optimizations, and enhanced API
*
* @param props - Configuration options for the marker
* @returns Enhanced actions and state for the marker
*/
export declare function useCreateMarker({ map: mapRef, lnglat: lnglatVal, popup: popupRef, el, options, on, debug, autoAdd, }: CreateMarkerProps): CreateMarkerActions;
export {};
//# sourceMappingURL=useCreateMarker.d.ts.map