import 'leaflet.locatecontrol'; import * as L from 'leaflet'; import { AWCLeafletElement } from '../../internal/awc-leaflet.js'; import type { LatLngBounds, LocationEvent } from 'leaflet'; /** * @summary Element which controls geolocation * @documentation https://webcomponents.adeliom.io/?path=/docs/components-map-controls-geolocation--documentation * @status experimental * @since 1.0 * * @event awc-map - type : locationfound - when geolocation (using the locate method) went successfully. * @event awc-map - type : locationerror - when geolocation (using the locate method) failed. */ export default class AWCMapGeolocation extends AWCLeafletElement { container: L.Map; control: L.Control.Locate & { _icon?: HTMLElement; }; private readonly localize; /** * The position of the control (one of the map corners). * Possible values are 'topleft', 'topright', 'bottomleft' or 'bottomright' */ position: 'topleft' | 'topright' | 'bottomleft' | 'bottomright'; /** * The `start` attribute sets wether location should be detected immediately using W3C geolocation method. You can later stop watching using map.stop() method. */ start: boolean; /** * The `watch` attribute sets wether location changes should be continous watching (instead of detecting it once) using W3C watchPosition method. You can later stop watching using map.stop() method. */ watch: boolean; /** * The `set-view` attribute sets whether the map view to the user location with respect to detection accuracy, or to world view if geolocation failed. * */ setView: false | 'once' | 'always' | 'untilPan' | 'untilPanOrZoom'; /** * Keep the current map zoom level when setting the view and only pan. */ keepCurrentZoomLevel: boolean; /** * After activating the plugin by clicking on the icon, zoom to the selected zoom level, even when keepCurrentZoomLevel is true. Set to 'false' to disable this feature. */ initialZoomLevel: false | number; /** * Smooth pan and zoom to the location of the marker. */ flyTo: boolean; /** * The user location can be inside and outside the current view when the user clicks on the * control that is already active. Both cases can be configures separately. * Possible values are: * - 'setView': zoom and pan to the current location * - 'stop': stop locating and remove the location marker */ clickBehavior: { /** What should happen if the user clicks on the control while the location is within the current view. */ inView: string; /** What should happen if the user clicks on the control while the location is outside the current view. */ outOfView: string; /** * What should happen if the user clicks on the control while the location is within the current view * and we could be following but are not. Defaults to a special value which inherits from 'inView'; */ inViewNotFollowing: string; }; /** * If set, save the map bounds just before centering to the user's * location. When control is disabled, set the view back to the * bounds that were saved. */ returnToPrevBounds: boolean; /** * Keep a cache of the location after the user deactivates the control. If set to false, the user has to wait * until the locate API returns a new location before they see where they are again. */ cacheLocation: boolean; /** If set, a circle that shows the location accuracy is drawn. */ drawCircle: boolean; /** If set, the marker at the users' location is drawn. */ drawMarker: boolean; /** If set and supported then show the compass heading */ showCompass: boolean; /** Display a pop-up when the user click on the inner marker. */ showPopup: boolean; /** Use metric units. */ metric: boolean; /** The `max-zoom` attribute sets the maximum zoom for automatic view setting when using `setView` option. */ maxZoom: number; /** The `timeout` attribute sets the number of milliseconds to wait for a response from geolocation before firing a locationerror event. */ timeout: number; /** * The `maximum-age` attribute sets maximum age of detected location. If less than this amount of milliseconds passed since last geolocation response, locate will return a cached location. */ maximumAge: number; /** * The `enable-high-accuracy` attribute sets whether high accuracy is enabled, see description in the W3C spec. */ enableHighAccuracy: boolean; /** * The `latitude` attribute returns the detected geographical location of the user. */ latitude: number | null; /** * The `longitude` attribute returns the detected geographical location of the user. */ longitude: number | null; /** * The `bounds` attribute returns the geographical bounds of the area user is located in (with respect to the accuracy of location). */ bounds: LatLngBounds | null; /** * The `accuracy` attribute returns the accuracy of location in meters. */ accuracy: number | null; /** * The `altitude` attribute returns the height of the position above the WGS84 ellipsoid in meters. */ altitude: number | null; /** * The `altitude-accuracy` attribute returns the accuracy of altitude in meters. * */ altitudeAccuracy: number | null; /** * The `heading` attribute returns the direction of travel in degrees counting clockwise from true North. */ heading: number | null; /** * The `speed` attribute returns the current velocity in meters per second. */ speed: number | null; /** * The `timestamp` attribute returns the time when the position was acquired. */ timestamp: number | null; /** * Accuracy circle style properties. NOTE these styles should match the css animations styles */ circleStyle?: L.PathOptions; /** * Inner marker style properties. Only works if your marker class supports `setStyle`. */ markerStyle?: L.CircleMarkerOptions | L.MarkerOptions; /** * Compass style properties. */ compassStyle?: L.CircleMarkerOptions & { width: number; depth: number; }; /** * The `icon` attribute sets the icon for the locate control. * */ icon: string; containerChanged(): void; disconnectedCallback(): void; onLocationfound(e: LocationEvent): void; }