@stadiamaps/ferrostar-webcomponents 0.39.0 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,36 @@
1
+ import { ReactiveElement, PropertyValues } from 'lit';
2
+ import { SerializableNavState, NavigationController, RouteAdapter, TripState, Route } from '@stadiamaps/ferrostar';
3
+ import { StateProvider } from './types';
4
+ /**
5
+ * A core navigation component that handles navigation logic without UI.
6
+ */
7
+ export declare class FerrostarCore extends ReactiveElement implements StateProvider {
8
+ valhallaEndpointUrl: string;
9
+ profile: string;
10
+ httpClient?: Function;
11
+ locationProvider: any;
12
+ options: object;
13
+ protected _navState: SerializableNavState | null;
14
+ onNavigationStart?: () => void;
15
+ onNavigationStop?: () => void;
16
+ onTripStateChange?: (newState: TripState | null) => void;
17
+ /**
18
+ * Enables voice guidance via the web speech synthesis API.
19
+ * Defaults to false.
20
+ */
21
+ useVoiceGuidance: boolean;
22
+ shouldRecord: boolean;
23
+ routeAdapter: RouteAdapter | null;
24
+ navigationController: NavigationController | null;
25
+ lastSpokenUtteranceId: string | null;
26
+ constructor();
27
+ updated(changedProperties: PropertyValues<this>): void;
28
+ getRoutes(initialLocation: any, waypoints: any): Promise<Route[]>;
29
+ startNavigation(route: Route, config: any): void;
30
+ private saveRecording;
31
+ stopNavigation(): Promise<void>;
32
+ provideState(tripState: TripState): void;
33
+ private navStateUpdate;
34
+ private onLocationUpdated;
35
+ }
36
+ //# sourceMappingURL=ferrostar-core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ferrostar-core.d.ts","sourceRoot":"","sources":["../src/ferrostar-core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAEtD,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,SAAS,EACT,KAAK,EACN,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC;;GAEG;AACH,qBACa,aAAc,SAAQ,eAAgB,YAAW,aAAa;IAEzE,mBAAmB,EAAE,MAAM,CAAM;IAGjC,OAAO,EAAE,MAAM,CAAM;IAGrB,UAAU,CAAC,EAAE,QAAQ,CAAS;IAI9B,gBAAgB,EAAG,GAAG,CAAC;IAIvB,OAAO,EAAE,MAAM,CAAM;IAGrB,SAAS,CAAC,SAAS,EAAE,oBAAoB,GAAG,IAAI,CAAQ;IAGxD,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAG/B,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;IAG9B,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,GAAG,IAAI,KAAK,IAAI,CAAC;IAEzD;;;OAGG;IAEH,gBAAgB,EAAE,OAAO,CAAS;IAGlC,YAAY,EAAE,OAAO,CAAS;IAE9B,YAAY,EAAE,YAAY,GAAG,IAAI,CAAQ;IACzC,oBAAoB,EAAE,oBAAoB,GAAG,IAAI,CAAQ;IACzD,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAQ;;IAW5C,OAAO,CAAC,iBAAiB,EAAE,cAAc,CAAC,IAAI,CAAC;IAOzC,SAAS,CAAC,eAAe,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG;IAoCpD,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG;IA4BzC,OAAO,CAAC,aAAa;IAaf,cAAc;IAWpB,YAAY,CAAC,SAAS,EAAE,SAAS;IAUjC,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,iBAAiB;CAoC1B"}
@@ -1,28 +1,35 @@
1
1
  import { LitElement, PropertyValues } from 'lit';
2
- import { default as maplibregl, GeolocateControl, Map } from 'maplibre-gl';
3
- import { JsNavState, NavigationController, RouteAdapter, TripState } from '@stadiamaps/ferrostar';
2
+ import { default as maplibregl, GeolocateControl } from 'maplibre-gl';
3
+ import { Route, TripState } from '@stadiamaps/ferrostar';
4
+ import { StateProvider as StateProvider } from './types';
4
5
  /**
5
- * A MapLibre-based map component specialized for navigation.
6
+ * A MapLibre-based map component.
6
7
  */
7
8
  export declare class FerrostarMap extends LitElement {
8
- valhallaEndpointUrl: string;
9
- profile: string;
10
- httpClient?: Function;
11
- locationProvider: any;
12
- options: object;
13
- protected _navState: JsNavState | null;
14
- onNavigationStart?: (map: Map) => void;
15
- onNavigationStop?: (map: Map) => void;
16
- onTripStateChange?: (newState: TripState | null) => void;
9
+ /**
10
+ * The MapLibre map instance.
11
+ *
12
+ * You have to explicitly set this value when initializing
13
+ * the web component to provide your own map instance.
14
+ *
15
+ */
16
+ map: maplibregl.Map;
17
+ stateProvider: StateProvider | null;
17
18
  /**
18
19
  * Styles to load which will apply inside the component
19
20
  */
20
- customStyles?: object | null;
21
+ customStyles?: object;
22
+ tripState: TripState | null;
23
+ route: Route | null;
24
+ /**
25
+ * Determines whether the navigation user interface is displayed.
26
+ */
27
+ showNavigationUI: boolean;
21
28
  /**
22
- * Enables voice guidance via the web speech synthesis API.
23
- * Defaults to false.
29
+ * Should the user marker be shown on the map.
30
+ * This is optional and defaults to false.
24
31
  */
25
- useVoiceGuidance: boolean;
32
+ showUserMarker: boolean;
26
33
  /**
27
34
  * Automatically geolocates the user on map load.
28
35
  *
@@ -37,29 +44,57 @@ export declare class FerrostarMap extends LitElement {
37
44
  * Set this to false if you want to disable the geolocation control or bring your own.
38
45
  */
39
46
  addGeolocateControl: boolean;
40
- routeAdapter: RouteAdapter | null;
41
47
  /**
42
- * The MapLibre map instance.
43
- *
44
- * You have to explicitly set this value when initializing
45
- * the web component to provide your own map instance.
46
- *
48
+ * A callback function that is invoked when navigation is stopped.
49
+ * Optional: This function can be provided by the StateProvider.
50
+ */
51
+ onStopNavigation?: () => void;
52
+ /**
53
+ * The geolocate control instance.
47
54
  */
48
- map: maplibregl.Map;
49
55
  geolocateControl: GeolocateControl | null;
50
- navigationController: NavigationController | null;
51
- simulatedLocationMarker: maplibregl.Marker | null;
52
- lastSpokenUtteranceId: string | null;
56
+ private userLocationMarker;
53
57
  static styles: import('lit').CSSResult[];
54
58
  constructor();
55
- updated(changedProperties: PropertyValues<this>): void;
56
59
  firstUpdated(): void;
57
- getRoutes(initialLocation: any, waypoints: any): Promise<any>;
58
- startNavigation(route: any, config: any): void;
59
- stopNavigation(): Promise<void>;
60
- private navStateUpdate;
61
- private onLocationUpdated;
62
- private clearMap;
60
+ updated(changedProperties: PropertyValues<this>): void;
61
+ linkWith(stateProvider: StateProvider, showUserMarker?: boolean): void;
62
+ /**
63
+ * Renders the current tripState on the map.
64
+ */
65
+ private renderTripState;
66
+ /**
67
+ * Renders a route on the map.
68
+ * If a route already exists, it clears the previous route before rendering a new one.
69
+ * This method adds two layers to the map: the primary route layer and a border layer.
70
+ */
71
+ private renderRoute;
72
+ /**
73
+ * Renders or updates the user's location marker on the map. If a marker already exists, its position is updated.
74
+ * Otherwise, a new marker is created and added to the map.
75
+ */
76
+ private renderUserLocationMarker;
77
+ /**
78
+ * Updates the camera position and orientation on the map based on the navState.
79
+ * Adjusts the center of the map to the user's current location and sets the bearing
80
+ * based on the user's course over ground, if available.
81
+ */
82
+ private updateCamera;
83
+ /**
84
+ * Clears the route layers and source from the map if they exist.
85
+ */
86
+ private clearRoute;
87
+ /**
88
+ * Removes the user's location marker from the map if it exists and clears the reference.
89
+ */
90
+ private clearUserLocationMarker;
91
+ /**
92
+ * Stops the navigation process, and clears the navigation state.
93
+ *
94
+ * This includes resetting the simulation flag,
95
+ * and invoking the optional onStopNavigation callback if provided.
96
+ */
97
+ stopNavigation(): void;
63
98
  render(): import('lit-html').TemplateResult<1>;
64
99
  }
65
100
  //# sourceMappingURL=ferrostar-map.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ferrostar-map.d.ts","sourceRoot":"","sources":["../src/ferrostar-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,cAAc,EAAE,MAAM,KAAK,C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