@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
package/README.md
CHANGED
|
@@ -97,6 +97,85 @@ export class MapComponent {
|
|
|
97
97
|
}
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
+
## Overlays — popups and tooltips
|
|
101
|
+
|
|
102
|
+
Available since `0.3.0` from `@angular-helpers/openlayers/overlays`.
|
|
103
|
+
|
|
104
|
+
### `<ol-popup>` — declarative popup with content projection
|
|
105
|
+
|
|
106
|
+
The popup's host element is used directly as the underlying `ol/Overlay` element, so projected children stay inside Angular's view tree and benefit from change detection without any extra plumbing.
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
import { OlPopupComponent } from '@angular-helpers/openlayers/overlays';
|
|
110
|
+
|
|
111
|
+
@Component({
|
|
112
|
+
imports: [OlMapComponent, OlVectorLayerComponent, OlPopupComponent],
|
|
113
|
+
template: `
|
|
114
|
+
<ol-map [center]="[2.17, 41.38]" [zoom]="12">
|
|
115
|
+
<ol-vector-layer id="cities" [features]="cities()" />
|
|
116
|
+
|
|
117
|
+
<ol-popup
|
|
118
|
+
[position]="selectedCoord()"
|
|
119
|
+
[closeButton]="true"
|
|
120
|
+
[autoPan]="true"
|
|
121
|
+
(closed)="clearSelection()"
|
|
122
|
+
>
|
|
123
|
+
<h3>{{ selected()?.name }}</h3>
|
|
124
|
+
<p>{{ selected()?.description }}</p>
|
|
125
|
+
</ol-popup>
|
|
126
|
+
</ol-map>
|
|
127
|
+
`,
|
|
128
|
+
})
|
|
129
|
+
export class MyMap {
|
|
130
|
+
// …
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Setting `[position]="null"` hides the popup and emits `closed`.
|
|
135
|
+
|
|
136
|
+
### `[olTooltip]` — feature hover tooltip
|
|
137
|
+
|
|
138
|
+
```html
|
|
139
|
+
<ol-vector-layer
|
|
140
|
+
id="cities"
|
|
141
|
+
[features]="cities()"
|
|
142
|
+
[olTooltip]="'name'"
|
|
143
|
+
[olTooltipLayer]="'cities'"
|
|
144
|
+
/>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Reads `feature.get('name')` for any feature on layer `cities` under the cursor and renders a styled `<div role="tooltip">` near the pointer. Use the `.ol-tooltip` class to override the default look.
|
|
148
|
+
|
|
149
|
+
### `OlPopupService` — programmatic popups
|
|
150
|
+
|
|
151
|
+
Three content modes from a service:
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
const popups = inject(OlPopupService);
|
|
155
|
+
|
|
156
|
+
// 1) Plain text / HTMLElement
|
|
157
|
+
popups.open({
|
|
158
|
+
id: 'simple',
|
|
159
|
+
position: [2.17, 41.38],
|
|
160
|
+
content: 'Hello map',
|
|
161
|
+
positioning: 'bottom-center',
|
|
162
|
+
autoPan: true,
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// 2) Dynamic Angular component (createComponent + hostElement)
|
|
166
|
+
const handle = popups.openComponent({
|
|
167
|
+
id: 'city-popup',
|
|
168
|
+
position: [2.17, 41.38],
|
|
169
|
+
component: CityCardComponent,
|
|
170
|
+
bindings: [
|
|
171
|
+
inputBinding('city', () => selected()),
|
|
172
|
+
outputBinding<void>('closed', () => handle.close()),
|
|
173
|
+
],
|
|
174
|
+
});
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
`open` is idempotent by `id` and updates the existing overlay in place. `openComponent` always recreates the `ComponentRef` on a repeated id and disposes the previous one (`appRef.detachView` + `ref.destroy`) to avoid CD leaks. Calls made before the map is ready are queued and replayed on `OlMapService.onReady`.
|
|
178
|
+
|
|
100
179
|
## Architecture
|
|
101
180
|
|
|
102
181
|
### Data vs UI Separation
|