aur-openlayers 1.0.4 → 19.6.4

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 CHANGED
@@ -1,63 +1,63 @@
1
- # Lib
2
-
3
- This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.2.0.
4
-
5
- ## Code scaffolding
6
-
7
- Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
8
-
9
- ```bash
10
- ng generate component component-name
11
- ```
12
-
13
- For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
14
-
15
- ```bash
16
- ng generate --help
17
- ```
18
-
19
- ## Building
20
-
21
- To build the library, run:
22
-
23
- ```bash
24
- ng build lib
25
- ```
26
-
27
- This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
28
-
29
- ### Publishing the Library
30
-
31
- Once the project is built, you can publish your library by following these steps:
32
-
33
- 1. Navigate to the `dist` directory:
34
- ```bash
35
- cd dist/lib
36
- ```
37
-
38
- 2. Run the `npm publish` command to publish your library to the npm registry:
39
- ```bash
40
- npm publish
41
- ```
42
-
43
- ## Running unit tests
44
-
45
- To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
46
-
47
- ```bash
48
- ng test
49
- ```
50
-
51
- ## Running end-to-end tests
52
-
53
- For end-to-end (e2e) testing, run:
54
-
55
- ```bash
56
- ng e2e
57
- ```
58
-
59
- Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
60
-
61
- ## Additional Resources
62
-
63
- For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
1
+ # Lib
2
+
3
+ This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.2.0.
4
+
5
+ ## Code scaffolding
6
+
7
+ Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
8
+
9
+ ```bash
10
+ ng generate component component-name
11
+ ```
12
+
13
+ For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
14
+
15
+ ```bash
16
+ ng generate --help
17
+ ```
18
+
19
+ ## Building
20
+
21
+ To build the library, run:
22
+
23
+ ```bash
24
+ ng build lib
25
+ ```
26
+
27
+ This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
28
+
29
+ ### Publishing the Library
30
+
31
+ Once the project is built, you can publish your library by following these steps:
32
+
33
+ 1. Navigate to the `dist` directory:
34
+ ```bash
35
+ cd dist/lib
36
+ ```
37
+
38
+ 2. Run the `npm publish` command to publish your library to the npm registry:
39
+ ```bash
40
+ npm publish
41
+ ```
42
+
43
+ ## Running unit tests
44
+
45
+ To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
46
+
47
+ ```bash
48
+ ng test
49
+ ```
50
+
51
+ ## Running end-to-end tests
52
+
53
+ For end-to-end (e2e) testing, run:
54
+
55
+ ```bash
56
+ ng e2e
57
+ ```
58
+
59
+ Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
60
+
61
+ ## Additional Resources
62
+
63
+ For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
@@ -3,12 +3,12 @@ import { Injectable, Component } from '@angular/core';
3
3
  import VectorLayer from 'ol/layer/Vector';
4
4
  import ClusterSource from 'ol/source/Cluster';
5
5
  import VectorSource from 'ol/source/Vector';
6
+ import { createEmpty, extend, isEmpty } from 'ol/extent';
6
7
  import Feature from 'ol/Feature';
7
8
  import Collection from 'ol/Collection';
8
9
  import DragPan from 'ol/interaction/DragPan';
9
10
  import Modify from 'ol/interaction/Modify';
10
11
  import * as Observable from 'ol/Observable';
11
- import { createEmpty, extend, isEmpty } from 'ol/extent';
12
12
 
13
13
  class LibService {
14
14
  constructor() { }
@@ -24,18 +24,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImpo
24
24
 
25
25
  class LibComponent {
26
26
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: LibComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
27
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.18", type: LibComponent, isStandalone: true, selector: "lib-lib", ngImport: i0, template: `
28
- <p>
29
- lib works!
30
- </p>
27
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.18", type: LibComponent, isStandalone: true, selector: "lib-lib", ngImport: i0, template: `
28
+ <p>
29
+ lib works!
30
+ </p>
31
31
  `, isInline: true, styles: [""] });
32
32
  }
33
33
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: LibComponent, decorators: [{
34
34
  type: Component,
35
- args: [{ selector: 'lib-lib', imports: [], template: `
36
- <p>
37
- lib works!
38
- </p>
35
+ args: [{ selector: 'lib-lib', imports: [], template: `
36
+ <p>
37
+ lib works!
38
+ </p>
39
39
  ` }]
40
40
  }] });
41
41
 
@@ -161,34 +161,6 @@ class FlushScheduler {
161
161
  }
162
162
  }
163
163
 
164
- const createMapContext = (map, layers, popupHost, scheduler = new FlushScheduler()) => {
165
- return {
166
- map,
167
- layers,
168
- popupHost,
169
- batch: (fn, options) => scheduler.batch(fn, options),
170
- };
171
- };
172
-
173
- const CLUSTER_FEATURES_KEY = 'features';
174
- const getClusterFeatures = (feature) => {
175
- const features = feature.get(CLUSTER_FEATURES_KEY);
176
- if (!Array.isArray(features)) {
177
- return null;
178
- }
179
- const items = features.filter((item) => {
180
- if (!item || typeof item !== 'object') {
181
- return false;
182
- }
183
- const candidate = item;
184
- return typeof candidate.get === 'function' && typeof candidate.getGeometry === 'function';
185
- });
186
- if (items.length === 0) {
187
- return null;
188
- }
189
- return items;
190
- };
191
-
192
164
  /**
193
165
  * Default padding for View#fit in pixels.
194
166
  * Order: [top, right, bottom, left]
@@ -208,16 +180,71 @@ function toOlPadding(p, fallback = DEFAULT_OL_PADDING) {
208
180
  }
209
181
  return [p.top, p.right, p.bottom, p.left];
210
182
  }
211
- function toOlFitOptions(opts) {
183
+ function toOlFitOptions(opts, map) {
212
184
  const padding = toOlPadding(opts?.padding) ?? DEFAULT_OL_PADDING;
213
185
  const duration = opts?.duration ?? DEFAULT_FIT_DURATION;
214
186
  // OL View#fit options are a plain object; keep it minimal & typed-friendly
215
187
  const fitOpts = { padding, duration };
216
- if (opts?.maxZoom != null) {
188
+ if (opts?.keepZoom && map) {
189
+ fitOpts.maxZoom = map.getView().getZoom();
190
+ }
191
+ else if (opts?.maxZoom != null) {
217
192
  fitOpts.maxZoom = opts.maxZoom;
218
193
  }
219
194
  return fitOpts;
220
195
  }
196
+ function collectLayersExtent(layers, layerIds) {
197
+ const extent = createEmpty();
198
+ const ids = layerIds ?? Object.keys(layers);
199
+ for (const id of ids) {
200
+ const layer = layers[id];
201
+ if (!layer || !layer.isVisible())
202
+ continue;
203
+ const layerExtent = layer.getExtent();
204
+ if (layerExtent) {
205
+ extend(extent, layerExtent);
206
+ }
207
+ }
208
+ return isEmpty(extent) ? null : extent;
209
+ }
210
+
211
+ const createMapContext = (map, layers, popupHost, scheduler = new FlushScheduler()) => {
212
+ return {
213
+ map,
214
+ layers,
215
+ popupHost,
216
+ batch: (fn, options) => scheduler.batch(fn, options),
217
+ centerOnAllLayers: (opts) => {
218
+ const extent = collectLayersExtent(layers);
219
+ if (extent)
220
+ map.getView().fit(extent, toOlFitOptions(opts, map));
221
+ },
222
+ centerOnLayers: (layerIds, opts) => {
223
+ const extent = collectLayersExtent(layers, layerIds);
224
+ if (extent)
225
+ map.getView().fit(extent, toOlFitOptions(opts, map));
226
+ },
227
+ };
228
+ };
229
+
230
+ const CLUSTER_FEATURES_KEY = 'features';
231
+ const getClusterFeatures = (feature) => {
232
+ const features = feature.get(CLUSTER_FEATURES_KEY);
233
+ if (!Array.isArray(features)) {
234
+ return null;
235
+ }
236
+ const items = features.filter((item) => {
237
+ if (!item || typeof item !== 'object') {
238
+ return false;
239
+ }
240
+ const candidate = item;
241
+ return typeof candidate.get === 'function' && typeof candidate.getGeometry === 'function';
242
+ });
243
+ if (items.length === 0) {
244
+ return null;
245
+ }
246
+ return items;
247
+ };
221
248
 
222
249
  const STATES_KEY = '__mff_states__';
223
250
  const getFeatureStates = (feature) => {
@@ -1862,7 +1889,7 @@ class VectorLayerBase {
1862
1889
  if (!extent || isEmpty(extent)) {
1863
1890
  return;
1864
1891
  }
1865
- this.ctx.map.getView().fit(extent, toOlFitOptions(opts));
1892
+ this.ctx.map.getView().fit(extent, toOlFitOptions(opts, this.ctx.map));
1866
1893
  }
1867
1894
  /** Fit view to a single feature by id. No-op if feature/geometry is missing. */
1868
1895
  centerOnModel(id, opts) {
@@ -1871,7 +1898,7 @@ class VectorLayerBase {
1871
1898
  if (!geom) {
1872
1899
  return;
1873
1900
  }
1874
- this.ctx.map.getView().fit(geom.getExtent(), toOlFitOptions(opts));
1901
+ this.ctx.map.getView().fit(geom.getExtent(), toOlFitOptions(opts, this.ctx.map));
1875
1902
  }
1876
1903
  /**
1877
1904
  * Fit view to a subset of features by ids (combined extent).
@@ -1891,7 +1918,11 @@ class VectorLayerBase {
1891
1918
  if (!found || isEmpty(extent)) {
1892
1919
  return;
1893
1920
  }
1894
- this.ctx.map.getView().fit(extent, toOlFitOptions(opts));
1921
+ this.ctx.map.getView().fit(extent, toOlFitOptions(opts, this.ctx.map));
1922
+ }
1923
+ getExtent() {
1924
+ const extent = this.source.getExtent();
1925
+ return isEmpty(extent) ? null : extent;
1895
1926
  }
1896
1927
  setVisible(visible) {
1897
1928
  this.layer.setVisible(visible);