location-picker
Version:
An open source location picker plugin using Google Maps v3 that works with all JavaScript flavors!
47 lines • 1.93 kB
TypeScript
import './location-picker.css';
export interface LatLng {
lat: number;
lng: number;
}
export interface LocationPickerOptions {
/** Attempt to set the map center to the user's current position via Geolocation. Defaults to true. */
setCurrentPosition?: boolean;
/** Initial latitude. If provided along with `lng`, geolocation is skipped. */
lat?: number;
/** Initial longitude. If provided along with `lat`, geolocation is skipped. */
lng?: number;
/**
* Use `google.maps.marker.AdvancedMarkerElement` instead of the CSS pin overlay when
* available. Requires the `marker` library to be loaded.
*/
useAdvancedMarker?: boolean;
/** Fired on every `idle` event with the new marker (map center) position. */
onLocationChange?: (pos: LatLng) => void;
}
/**
* LocationPicker - wraps a Google Map so the user can drag the map and the centered
* marker reports the chosen position.
*/
export declare class LocationPicker {
element: HTMLElement | null;
map: google.maps.Map;
private readonly options;
private markerNode;
private advancedMarker;
private idleListener;
constructor(element: string | HTMLElement, options?: LocationPickerOptions, mapOptions?: google.maps.MapOptions);
/** Current marker position (map center). */
getMarkerPosition(): LatLng;
/** Center the map (and marker) on the given coordinates. */
setLocation(lat: number, lng: number): void;
/**
* Request the user's current position via the Geolocation API and center the map on it.
* Resolves with the resolved coordinates, rejects if geolocation is unavailable or denied.
*/
setCurrentPosition(): Promise<LatLng>;
/** Remove listeners, marker DOM nodes, and related classes. The map instance is released. */
destroy(): void;
private initMarker;
}
export default LocationPicker;
//# sourceMappingURL=location-picker.d.ts.map