@angular-helpers/openlayers 0.1.1 → 0.3.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.
- package/README.md +79 -0
- package/fesm2022/angular-helpers-openlayers-controls.mjs +496 -107
- package/fesm2022/angular-helpers-openlayers-core.mjs +130 -32
- package/fesm2022/angular-helpers-openlayers-interactions.mjs +583 -10
- package/fesm2022/angular-helpers-openlayers-layers.mjs +318 -49
- package/fesm2022/angular-helpers-openlayers-overlays.mjs +437 -7
- package/package.json +3 -2
- package/types/angular-helpers-openlayers-controls.d.ts +161 -23
- package/types/angular-helpers-openlayers-core.d.ts +72 -7
- package/types/angular-helpers-openlayers-interactions.d.ts +315 -6
- package/types/angular-helpers-openlayers-layers.d.ts +61 -10
- package/types/angular-helpers-openlayers-overlays.d.ts +196 -11
|
@@ -1,29 +1,214 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { Type, Binding, Injector } from '@angular/core';
|
|
1
3
|
import { Coordinate, OlFeature } from '@angular-helpers/openlayers/core';
|
|
2
|
-
import * as i0 from '@angular/core';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Anchor of the overlay element relative to its `position` coordinate.
|
|
7
|
+
* Mirrors the values accepted by `ol/Overlay#setPositioning`.
|
|
8
|
+
*/
|
|
9
|
+
type OverlayPositioning = 'bottom-left' | 'bottom-center' | 'bottom-right' | 'center-left' | 'center-center' | 'center-right' | 'top-left' | 'top-center' | 'top-right';
|
|
10
|
+
/**
|
|
11
|
+
* Common positioning options shared by every popup mode.
|
|
12
|
+
*/
|
|
5
13
|
interface OverlayConfig {
|
|
6
|
-
|
|
14
|
+
positioning?: OverlayPositioning;
|
|
7
15
|
offset?: [number, number];
|
|
16
|
+
className?: string;
|
|
17
|
+
autoPan?: boolean;
|
|
8
18
|
}
|
|
9
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Options for `OlPopupService.open()` — string / HTMLElement content.
|
|
21
|
+
*/
|
|
22
|
+
interface PopupOpenOptions extends OverlayConfig {
|
|
23
|
+
/** Unique id for the popup. Generated when omitted. */
|
|
10
24
|
id?: string;
|
|
25
|
+
/** Map coordinate where the popup is anchored. */
|
|
26
|
+
position: Coordinate;
|
|
27
|
+
/**
|
|
28
|
+
* Popup content. A `string` is rendered as text via `textContent` (no HTML parsing).
|
|
29
|
+
* Pass an `HTMLElement` when richer DOM is required.
|
|
30
|
+
*/
|
|
11
31
|
content: string | HTMLElement;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Options for `OlPopupService.openComponent()` — dynamic Angular component content.
|
|
35
|
+
*
|
|
36
|
+
* Internally uses `createComponent + hostElement` (Angular 16.2+) so consumers can wire
|
|
37
|
+
* `inputBinding` / `outputBinding` / `twoWayBinding` declaratively.
|
|
38
|
+
*/
|
|
39
|
+
interface PopupComponentOptions<C> extends OverlayConfig {
|
|
40
|
+
id?: string;
|
|
12
41
|
position: Coordinate;
|
|
42
|
+
/** The component class to instantiate. */
|
|
43
|
+
component: Type<C>;
|
|
44
|
+
/** Bindings created via `inputBinding`, `outputBinding`, `twoWayBinding`. */
|
|
45
|
+
bindings?: Binding[];
|
|
46
|
+
/** Optional host directives applied to the dynamically-created component. */
|
|
47
|
+
directives?: ReadonlyArray<Type<unknown> | {
|
|
48
|
+
readonly type: Type<unknown>;
|
|
49
|
+
readonly bindings?: Binding[];
|
|
50
|
+
}>;
|
|
51
|
+
/** Optional element injector for the component (defaults to the service's injector). */
|
|
52
|
+
injector?: Injector;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Handle returned by `OlPopupService.open()` and `openComponent()`.
|
|
56
|
+
* Use it to close the popup imperatively without going through the service.
|
|
57
|
+
*/
|
|
58
|
+
interface PopupHandle {
|
|
59
|
+
readonly id: string;
|
|
60
|
+
close(): void;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* @deprecated Use {@link PopupOpenOptions} instead. Kept for backwards compatibility
|
|
64
|
+
* with the v0.2.x stub API and removed in a future major version.
|
|
65
|
+
*/
|
|
66
|
+
type PopupOptions = PopupOpenOptions & {
|
|
67
|
+
/** No-op flag retained for source compatibility. */
|
|
13
68
|
autoClose?: boolean;
|
|
69
|
+
/** Whether to render the default close button (deprecated, prefer `<ol-popup>`). */
|
|
14
70
|
closeButton?: boolean;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* @deprecated Use {@link OverlayPositioning} instead.
|
|
74
|
+
*/
|
|
75
|
+
type OverlayPosition = OverlayPositioning;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Declarative map popup that projects arbitrary Angular content via `<ng-content>`.
|
|
79
|
+
*
|
|
80
|
+
* The component's host element is used directly as the `ol/Overlay`'s element, so
|
|
81
|
+
* projected children stay inside Angular's component tree and benefit from change
|
|
82
|
+
* detection without any extra plumbing.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```html
|
|
86
|
+
* <ol-popup
|
|
87
|
+
* [position]="selectedCoord()"
|
|
88
|
+
* [closeButton]="true"
|
|
89
|
+
* [autoPan]="true"
|
|
90
|
+
* (closed)="clearSelection()"
|
|
91
|
+
* >
|
|
92
|
+
* <h3>{{ selected()?.name }}</h3>
|
|
93
|
+
* <p>{{ selected()?.description }}</p>
|
|
94
|
+
* </ol-popup>
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
declare class OlPopupComponent {
|
|
98
|
+
private readonly elementRef;
|
|
99
|
+
private readonly mapService;
|
|
100
|
+
private readonly zoneHelper;
|
|
101
|
+
/** Map coordinate where the popup is anchored. `null` hides the popup. */
|
|
102
|
+
readonly position: _angular_core.InputSignal<Coordinate>;
|
|
103
|
+
/** Pixel offset relative to `position`. */
|
|
104
|
+
readonly offset: _angular_core.InputSignal<[number, number]>;
|
|
105
|
+
/** Anchor of the popup element relative to `position`. */
|
|
106
|
+
readonly positioning: _angular_core.InputSignal<OverlayPositioning>;
|
|
107
|
+
/** Whether the map auto-pans to keep the popup in view. */
|
|
108
|
+
readonly autoPan: _angular_core.InputSignal<boolean>;
|
|
109
|
+
/** Whether to render the default close button. */
|
|
110
|
+
readonly closeButton: _angular_core.InputSignal<boolean>;
|
|
111
|
+
/** Emitted when the popup transitions from visible to hidden (close button or `position` set to null). */
|
|
112
|
+
readonly closed: _angular_core.OutputEmitterRef<void>;
|
|
113
|
+
private overlay;
|
|
114
|
+
private currentMap;
|
|
115
|
+
private wasVisible;
|
|
116
|
+
constructor();
|
|
117
|
+
/** @internal */
|
|
118
|
+
onCloseClick(): void;
|
|
119
|
+
private applyState;
|
|
120
|
+
private dispose;
|
|
121
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<OlPopupComponent, never>;
|
|
122
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<OlPopupComponent, "ol-popup", never, { "position": { "alias": "position"; "required": false; "isSignal": true; }; "offset": { "alias": "offset"; "required": false; "isSignal": true; }; "positioning": { "alias": "positioning"; "required": false; "isSignal": true; }; "autoPan": { "alias": "autoPan"; "required": false; "isSignal": true; }; "closeButton": { "alias": "closeButton"; "required": false; "isSignal": true; }; }, { "closed": "closed"; }, never, ["*"], true, never>;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Shows a floating tooltip whose text is read from a feature property when the
|
|
127
|
+
* pointer hovers over it. The tooltip element is appended to the map viewport
|
|
128
|
+
* and styled minimally; consumers can override via the `.ol-tooltip` CSS hook.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```html
|
|
132
|
+
* <ol-vector-layer
|
|
133
|
+
* id="cities"
|
|
134
|
+
* [features]="cities()"
|
|
135
|
+
* [olTooltip]="'name'"
|
|
136
|
+
* />
|
|
137
|
+
* ```
|
|
138
|
+
*
|
|
139
|
+
* Apply `[olTooltipLayer]` to limit detection to a single layer (matches the
|
|
140
|
+
* value of the layer's `id` property). Without it the tooltip reacts to any
|
|
141
|
+
* feature found at the cursor.
|
|
142
|
+
*/
|
|
143
|
+
declare class OlTooltipDirective {
|
|
144
|
+
private readonly mapService;
|
|
145
|
+
private readonly zoneHelper;
|
|
146
|
+
/** Property key to read from the hovered feature. */
|
|
147
|
+
readonly olTooltip: _angular_core.InputSignal<string>;
|
|
148
|
+
/** Optional layer id; when set, only features on that layer trigger the tooltip. */
|
|
149
|
+
readonly olTooltipLayer: _angular_core.InputSignal<string>;
|
|
150
|
+
private element;
|
|
151
|
+
private listener;
|
|
152
|
+
private currentMap;
|
|
153
|
+
constructor();
|
|
154
|
+
private handlePointerMove;
|
|
155
|
+
private dispose;
|
|
156
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<OlTooltipDirective, never>;
|
|
157
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<OlTooltipDirective, "[olTooltip]", never, { "olTooltip": { "alias": "olTooltip"; "required": true; "isSignal": true; }; "olTooltipLayer": { "alias": "olTooltipLayer"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
15
158
|
}
|
|
16
159
|
|
|
160
|
+
/**
|
|
161
|
+
* Manages OpenLayers popup overlays anchored to map coordinates.
|
|
162
|
+
*
|
|
163
|
+
* Three content modes:
|
|
164
|
+
* - `open()` — string text or `HTMLElement`
|
|
165
|
+
* - `openComponent()` — dynamic Angular component via `createComponent + hostElement`
|
|
166
|
+
* - The `<ol-popup>` component delegates `open()` internally for declarative usage.
|
|
167
|
+
*
|
|
168
|
+
* All calls are idempotent by `id`. Calls made before the underlying `ol/Map` is ready
|
|
169
|
+
* are queued and replayed in order once `OlMapService.onReady` fires.
|
|
170
|
+
*/
|
|
17
171
|
declare class OlPopupService {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
172
|
+
private readonly mapService;
|
|
173
|
+
private readonly zoneHelper;
|
|
174
|
+
private readonly envInjector;
|
|
175
|
+
private readonly appRef;
|
|
176
|
+
private readonly popups;
|
|
177
|
+
private readonly pending;
|
|
178
|
+
private flushSubscribed;
|
|
179
|
+
constructor();
|
|
180
|
+
/**
|
|
181
|
+
* Open a popup with `string` or `HTMLElement` content.
|
|
182
|
+
*
|
|
183
|
+
* Idempotent by `id`: a second call with the same id updates `position` and
|
|
184
|
+
* `content` of the existing popup instead of creating a duplicate.
|
|
185
|
+
*/
|
|
186
|
+
open(options: PopupOpenOptions): PopupHandle;
|
|
187
|
+
/**
|
|
188
|
+
* Open a popup whose content is a dynamically-instantiated Angular component.
|
|
189
|
+
*
|
|
190
|
+
* Uses `createComponent({ environmentInjector, hostElement, bindings, directives })`
|
|
191
|
+
* (Angular 16.2+) and attaches the host view to `ApplicationRef` so change detection
|
|
192
|
+
* reaches the rendered component.
|
|
193
|
+
*
|
|
194
|
+
* Idempotent by `id`: a previous `ComponentRef` registered under the same id is
|
|
195
|
+
* destroyed before the new one is created.
|
|
196
|
+
*/
|
|
197
|
+
openComponent<C>(options: PopupComponentOptions<C>): PopupHandle;
|
|
198
|
+
/** Close and dispose a single popup by id. No-op when the id is unknown. */
|
|
199
|
+
close(id: string): void;
|
|
200
|
+
/** Close every managed popup. */
|
|
201
|
+
closeAll(): void;
|
|
202
|
+
private queue;
|
|
203
|
+
private flushPending;
|
|
204
|
+
private createOrUpdate;
|
|
205
|
+
private createOrUpdateComponent;
|
|
206
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<OlPopupService, never>;
|
|
207
|
+
static ɵprov: _angular_core.ɵɵInjectableDeclaration<OlPopupService>;
|
|
23
208
|
}
|
|
24
209
|
|
|
25
210
|
declare function withOverlays(): OlFeature<'overlays'>;
|
|
26
211
|
declare function provideOverlays(): OlFeature<'overlays'>;
|
|
27
212
|
|
|
28
|
-
export { OlPopupService, provideOverlays, withOverlays };
|
|
29
|
-
export type { OverlayConfig, OverlayPosition, PopupOptions };
|
|
213
|
+
export { OlPopupComponent, OlPopupService, OlTooltipDirective, provideOverlays, withOverlays };
|
|
214
|
+
export type { OverlayConfig, OverlayPosition, OverlayPositioning, PopupComponentOptions, PopupHandle, PopupOpenOptions, PopupOptions };
|