ol 10.8.1-dev.1775310976144 → 10.8.1-dev.1775730134907
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/dist/ol.js +1 -1
- package/dist/ol.js.map +1 -1
- package/featureloader.d.ts +18 -16
- package/featureloader.d.ts.map +1 -1
- package/featureloader.js +9 -8
- package/package.json +1 -1
- package/renderer/canvas/TileLayer.d.ts +5 -0
- package/renderer/canvas/TileLayer.d.ts.map +1 -1
- package/renderer/canvas/TileLayer.js +14 -10
- package/renderer/canvas/VectorTileLayer.d.ts.map +1 -1
- package/renderer/canvas/VectorTileLayer.js +13 -0
- package/source/Source.d.ts +3 -3
- package/source/Source.d.ts.map +1 -1
- package/source/Source.js +2 -2
- package/source/Vector.d.ts +35 -47
- package/source/Vector.d.ts.map +1 -1
- package/source/Vector.js +60 -50
- package/util.js +1 -1
package/featureloader.d.ts
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
* {@link module:ol/source/Vector~VectorSource} sources use a function of this type to
|
|
3
3
|
* load features.
|
|
4
4
|
*
|
|
5
|
-
* This function takes
|
|
6
|
-
* the area to be loaded, a `{number}` representing the resolution (map units per pixel), a
|
|
7
|
-
* {@link module:ol/proj/Projection~Projection} for the projection
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
5
|
+
* This function takes 3 arguments: an {@link module:ol/extent~Extent} representing
|
|
6
|
+
* the area to be loaded, a `{number}` representing the resolution (map units per pixel), and a
|
|
7
|
+
* {@link module:ol/proj/Projection~Projection} for the projection. The function is expeced to return
|
|
8
|
+
* a promise that resolves to an array of features.
|
|
9
|
+
*
|
|
10
|
+
* There are also a deprecated signature, with `void` as
|
|
11
|
+
* return, and two additional arguments: an optional success callback that should get
|
|
12
|
+
* the loaded features passed as an argument and an optional failure callback with no arguments.
|
|
12
13
|
*
|
|
13
14
|
* The function is responsible for loading the features and adding them to the
|
|
14
15
|
* source.
|
|
@@ -19,7 +20,7 @@
|
|
|
19
20
|
* resolution: number,
|
|
20
21
|
* projection: import("./proj/Projection.js").default,
|
|
21
22
|
* success?: (features: Array<FeatureType>) => void,
|
|
22
|
-
* failure?: () => void) => void} FeatureLoader
|
|
23
|
+
* failure?: () => void) => void|Promise<Array<FeatureType>>} FeatureLoader
|
|
23
24
|
* @api
|
|
24
25
|
*/
|
|
25
26
|
/**
|
|
@@ -74,18 +75,19 @@ export function setWithCredentials(xhrWithCredentials: boolean): void;
|
|
|
74
75
|
* {@link module :ol/source/Vector~VectorSource} sources use a function of this type to
|
|
75
76
|
* load features.
|
|
76
77
|
*
|
|
77
|
-
* This function takes
|
|
78
|
-
* the area to be loaded, a `{number}` representing the resolution (map units per pixel), a
|
|
79
|
-
* {@link module :ol/proj/Projection~Projection} for the projection
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
78
|
+
* This function takes 3 arguments: an {@link module :ol/extent~Extent} representing
|
|
79
|
+
* the area to be loaded, a `{number}` representing the resolution (map units per pixel), and a
|
|
80
|
+
* {@link module :ol/proj/Projection~Projection} for the projection. The function is expeced to return
|
|
81
|
+
* a promise that resolves to an array of features.
|
|
82
|
+
*
|
|
83
|
+
* There are also a deprecated signature, with `void` as
|
|
84
|
+
* return, and two additional arguments: an optional success callback that should get
|
|
85
|
+
* the loaded features passed as an argument and an optional failure callback with no arguments.
|
|
84
86
|
*
|
|
85
87
|
* The function is responsible for loading the features and adding them to the
|
|
86
88
|
* source.
|
|
87
89
|
*/
|
|
88
|
-
export type FeatureLoader<FeatureType extends import("./Feature.js").FeatureLike = import("./Feature.js").FeatureLike> = (extent: import("./extent.js").Extent, resolution: number, projection: import("./proj/Projection.js").default, success?: (features: Array<FeatureType>) => void, failure?: () => void) => void
|
|
90
|
+
export type FeatureLoader<FeatureType extends import("./Feature.js").FeatureLike = import("./Feature.js").FeatureLike> = (extent: import("./extent.js").Extent, resolution: number, projection: import("./proj/Projection.js").default, success?: (features: Array<FeatureType>) => void, failure?: () => void) => void | Promise<Array<FeatureType>>;
|
|
89
91
|
/**
|
|
90
92
|
* {@link module :ol/source/Vector~VectorSource} sources use a function of this type to
|
|
91
93
|
* get the url to load features from.
|
package/featureloader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"featureloader.d.ts","sourceRoot":"","sources":["featureloader.js"],"names":[],"mappings":"AAWA
|
|
1
|
+
{"version":3,"file":"featureloader.d.ts","sourceRoot":"","sources":["featureloader.js"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;;;;;;;GAUG;AAEH;;;;;;;;;;;GAWG;AACH,gCAXmD,WAAW,SAAjD,OAAQ,cAAc,EAAE,WAAY;;SACtC,MAAM,GAAC,kBAAkB,UACzB,OAAO,qBAAqB,EAAE,OAAO,CAAC,WAAW,CAAC,UAClD,OAAO,aAAa,EAAE,MAAM,cAC5B,MAAM,cACN,OAAO,sBAAsB,EAAE,OAAO,WACtC,CAAS,IAAkB,EAAlB,KAAK,CAAC,WAAW,CAAC,EAAE,IAAsC,EAAtC,OAAO,sBAAsB,EAAE,OAAO,KAAG,IAAI,WAE1E,MAAY,IAAI,QAkE1B;AAED;;;;;;;;;;GAUG;AACH,oBANmD,WAAW,SAAjD,OAAQ,cAAc,EAAE,WAAY;;SACtC,MAAM,GAAC,kBAAkB,UACzB,OAAO,qBAAqB,EAAE,OAAO,CAAC,WAAW,CAAC,GACjD,aAAa,CAAC,WAAW,CAAC,CAwCrC;AAED;;;;;;GAMG;AACH,uDAJW,OAAO,QAMjB;;;;;;;;;;;;;;;;;0BA9JkD,WAAW,SAAjD,OAAQ,cAAc,EAAE,WAAY,yCACpC,CACA,MAAM,EAAE,OAAO,aAAa,EAAE,MAAM,EACpC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,OAAO,sBAAsB,EAAE,OAAO,EAClD,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,KAAK,IAAI,EAChD,OAAO,CAAC,EAAE,MAAM,IAAI,KAAK,IAAI,GAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;;;;;;;;;;iCAYzD,CAAS,IAA4B,EAA5B,OAAO,aAAa,EAAE,MAAM,EAAE,IAAM,EAAN,MAAM,EAAE,IAAsC,EAAtC,OAAO,sBAAsB,EAAE,OAAO,KAAG,MAAM"}
|
package/featureloader.js
CHANGED
|
@@ -13,13 +13,14 @@ let withCredentials = false;
|
|
|
13
13
|
* {@link module:ol/source/Vector~VectorSource} sources use a function of this type to
|
|
14
14
|
* load features.
|
|
15
15
|
*
|
|
16
|
-
* This function takes
|
|
17
|
-
* the area to be loaded, a `{number}` representing the resolution (map units per pixel), a
|
|
18
|
-
* {@link module:ol/proj/Projection~Projection} for the projection
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
16
|
+
* This function takes 3 arguments: an {@link module:ol/extent~Extent} representing
|
|
17
|
+
* the area to be loaded, a `{number}` representing the resolution (map units per pixel), and a
|
|
18
|
+
* {@link module:ol/proj/Projection~Projection} for the projection. The function is expeced to return
|
|
19
|
+
* a promise that resolves to an array of features.
|
|
20
|
+
*
|
|
21
|
+
* There are also a deprecated signature, with `void` as
|
|
22
|
+
* return, and two additional arguments: an optional success callback that should get
|
|
23
|
+
* the loaded features passed as an argument and an optional failure callback with no arguments.
|
|
23
24
|
*
|
|
24
25
|
* The function is responsible for loading the features and adding them to the
|
|
25
26
|
* source.
|
|
@@ -30,7 +31,7 @@ let withCredentials = false;
|
|
|
30
31
|
* resolution: number,
|
|
31
32
|
* projection: import("./proj/Projection.js").default,
|
|
32
33
|
* success?: (features: Array<FeatureType>) => void,
|
|
33
|
-
* failure?: () => void) => void} FeatureLoader
|
|
34
|
+
* failure?: () => void) => void|Promise<Array<FeatureType>>} FeatureLoader
|
|
34
35
|
* @api
|
|
35
36
|
*/
|
|
36
37
|
|
package/package.json
CHANGED
|
@@ -90,6 +90,11 @@ declare class CanvasTileLayerRenderer<LayerType extends import("../../layer/Tile
|
|
|
90
90
|
* @private
|
|
91
91
|
*/
|
|
92
92
|
private sourceTileCache_;
|
|
93
|
+
/**
|
|
94
|
+
* @protected
|
|
95
|
+
* @type {import("../../extent.js").Extent|null}
|
|
96
|
+
*/
|
|
97
|
+
protected layerExtent: import("../../extent.js").Extent | null;
|
|
93
98
|
/**
|
|
94
99
|
* @return {LRUCache} Tile cache.
|
|
95
100
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileLayer.d.ts","sourceRoot":"","sources":["TileLayer.js"],"names":[],"mappings":";;;;;;;;;;AAkGA;;;GAGG;AAEH;;;;;;GAMG;AACH,sCAHkG,SAAS,SAA7F,OAAO,qBAAqB,EAAE,OAAO,GAAC,OAAO,2BAA2B,EAAE,OAAQ;IAI9F;;;OAGG;IACH,uBAHW,SAAS,YACT,OAAO,
|
|
1
|
+
{"version":3,"file":"TileLayer.d.ts","sourceRoot":"","sources":["TileLayer.js"],"names":[],"mappings":";;;;;;;;;;AAkGA;;;GAGG;AAEH;;;;;;GAMG;AACH,sCAHkG,SAAS,SAA7F,OAAO,qBAAqB,EAAE,OAAO,GAAC,OAAO,2BAA2B,EAAE,OAAQ;IAI9F;;;OAGG;IACH,uBAHW,SAAS,YACT,OAAO,EA8FjB;IAvFC;;;OAGG;IACH,eAFU,OAAO,CAEQ;IAEzB;;;OAGG;IACH,gBAFU,OAAO,CAEU;IAE3B;;;OAGG;IACH,wBAA2B;IAE3B;;;OAGG;IACH,8BAFU,MAAM,CAEO;IAEvB;;;OAGG;IACH,8BAFU,OAAO,0BAA0B,EAAE,OAAO,GAAC,IAAI,CAE3B;IAE9B;;;OAGG;IACH,yBAFW,KAAK,CAAC,OAAO,eAAe,EAAE,OAAO,CAAC,CAE1B;IAEvB;;;OAGG;IACH,2BAAuB;IAEvB;;;OAGG;IACH,gCAA4B;I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;;OAKG;IACH,6BAJW,OAAO,oBAAoB,EAAE,OAAO,GACnC,iBAAiB,GAAC,eAAe,GAAC,gBAAgB,GAAC,gBAAgB,CAK9E;IAED;;;;;OAKG;IACH,qCALW;YAAQ,MAAM,GAAE;gBAAQ,MAAM,GAAE,OAAO;SAAC;KAAC,cACzC,OAAO,sBAAsB,EAAE,OAAO,QACtC,OAAO,eAAe,EAAE,OAAO,QAUzC;CACF;gCA/8B+B,YAAY;qBAVvB,2BAA2B"}
|
|
@@ -198,6 +198,12 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
|
|
|
198
198
|
*/
|
|
199
199
|
this.sourceTileCache_ = null;
|
|
200
200
|
|
|
201
|
+
/**
|
|
202
|
+
* @protected
|
|
203
|
+
* @type {import("../../extent.js").Extent|null}
|
|
204
|
+
*/
|
|
205
|
+
this.layerExtent = null;
|
|
206
|
+
|
|
201
207
|
this.maxStaleKeys = cacheSize * 0.5;
|
|
202
208
|
}
|
|
203
209
|
|
|
@@ -617,13 +623,11 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
|
|
|
617
623
|
const width = this.context.canvas.width;
|
|
618
624
|
const height = this.context.canvas.height;
|
|
619
625
|
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
fromUserExtent(layerState.extent, projection),
|
|
626
|
-
);
|
|
626
|
+
this.layerExtent = layerState.extent
|
|
627
|
+
? fromUserExtent(layerState.extent, projection)
|
|
628
|
+
: null;
|
|
629
|
+
if (this.layerExtent) {
|
|
630
|
+
frameExtent = getIntersection(frameExtent, this.layerExtent);
|
|
627
631
|
}
|
|
628
632
|
|
|
629
633
|
const dx = (tileResolution * width) / 2 / tilePixelRatio;
|
|
@@ -758,8 +762,8 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
|
|
|
758
762
|
-height / 2,
|
|
759
763
|
);
|
|
760
764
|
|
|
761
|
-
if (
|
|
762
|
-
this.clipUnrotated(context, frameState, layerExtent);
|
|
765
|
+
if (this.layerExtent) {
|
|
766
|
+
this.clipUnrotated(context, frameState, this.layerExtent);
|
|
763
767
|
}
|
|
764
768
|
|
|
765
769
|
if (!tileSource.getInterpolate()) {
|
|
@@ -870,7 +874,7 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
|
|
|
870
874
|
|
|
871
875
|
this.postRender(this.context, frameState);
|
|
872
876
|
|
|
873
|
-
if (
|
|
877
|
+
if (this.layerExtent) {
|
|
874
878
|
context.restore();
|
|
875
879
|
}
|
|
876
880
|
context.imageSmoothingEnabled = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VectorTileLayer.d.ts","sourceRoot":"","sources":["VectorTileLayer.js"],"names":[],"mappings":";AA6DA;;;;;GAKG;AACH;IACE;;;OAGG;IACH,mBAHW,OAAO,2BAA2B,EAAE,OAAO,WAC3C,OAAO,gBAAgB,EAAE,OAAO,EA2C1C;IAtCC,eAAe;IACf,qCAA2E;IAE3E;;;OAGG;IACH,+BAA2B;IAE3B;;;OAGG;IACH,4CAA+C;IAE/C;;;OAGG;IACH,0BAAsB;IAEtB;;;OAGG;IACH,yBAAyB;IAEzB;;;OAGG;IACH,sBAAsC;IAEtC;;;OAGG;IACH,0BAA6B;IAY/B;;;;;;;;;;OAUG;IACH,wBAVW,OAAO,2BAA2B,EAAE,OAAO,cAC3C,OAAO,cAAc,EAAE,UAAU,KACjC,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,UACN,MAAM,cACN,OAAO,QAajB;IAoDD;;;;;OAKG;IACH,6BA8IC;IA0MD;;;OAGG;IACH,4BAHW,OAAO,iBAAiB,EAAE,MAAM,GAC/B,KAAK,CAAC,OAAO,kBAAkB,EAAE,WAAW,CAAC,CA4CxD;IAaD;;;;OAIG;IACH,gCAEC;IAED;;;;OAIG;IACH,4BAHW,OAAO,cAAc,EAAE,UAAU,cACjC,OAAO,sBAAsB,EAAE,KAAK,QAyC9C;
|
|
1
|
+
{"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CAl+BmC,gBAAgB"}
|
|
@@ -692,6 +692,9 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
|
|
|
692
692
|
}
|
|
693
693
|
}
|
|
694
694
|
const zIndexKeys = Object.keys(usedZIndices).map(Number).sort(ascending);
|
|
695
|
+
if (this.layerExtent) {
|
|
696
|
+
this.clipUnrotated(this.context, frameState, this.layerExtent);
|
|
697
|
+
}
|
|
695
698
|
zIndexKeys.forEach((zIndex) => {
|
|
696
699
|
executorGroupZIndexContexts.forEach((zIndexContexts, i) => {
|
|
697
700
|
if (!zIndexContexts[zIndex]) {
|
|
@@ -716,6 +719,9 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
|
|
|
716
719
|
zIndexContexts[zIndex].length = 0;
|
|
717
720
|
});
|
|
718
721
|
});
|
|
722
|
+
if (this.layerExtent) {
|
|
723
|
+
this.context.restore();
|
|
724
|
+
}
|
|
719
725
|
}
|
|
720
726
|
|
|
721
727
|
/**
|
|
@@ -787,6 +793,10 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
|
|
|
787
793
|
: VECTOR_REPLAYS[renderMode];
|
|
788
794
|
const viewState = frameState.viewState;
|
|
789
795
|
const rotation = viewState.rotation;
|
|
796
|
+
// clipped rendering if layer extent is set
|
|
797
|
+
if (this.layerExtent) {
|
|
798
|
+
this.clipUnrotated(context, frameState, this.layerExtent);
|
|
799
|
+
}
|
|
790
800
|
const tileSource = layer.getSource();
|
|
791
801
|
const tileGrid = tileSource.getTileGridForProjection(viewState.projection);
|
|
792
802
|
const z = tileGrid.getZForResolution(
|
|
@@ -878,6 +888,9 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
|
|
|
878
888
|
}
|
|
879
889
|
}
|
|
880
890
|
}
|
|
891
|
+
if (this.layerExtent) {
|
|
892
|
+
context.restore();
|
|
893
|
+
}
|
|
881
894
|
context.globalAlpha = alpha;
|
|
882
895
|
this.ready = ready;
|
|
883
896
|
this.tileClipContexts_ = tileClipContexts;
|
package/source/Source.d.ts
CHANGED
|
@@ -108,10 +108,10 @@ declare class Source extends BaseObject<{
|
|
|
108
108
|
private attributionsCollapsible_;
|
|
109
109
|
/**
|
|
110
110
|
* This source is currently loading data. Sources that defer loading to the
|
|
111
|
-
* map's tile queue never set this to `
|
|
112
|
-
* @type {boolean}
|
|
111
|
+
* map's tile queue never set this to a `truthy` value.
|
|
112
|
+
* @type {boolean|number}
|
|
113
113
|
*/
|
|
114
|
-
loading: boolean;
|
|
114
|
+
loading: boolean | number;
|
|
115
115
|
/**
|
|
116
116
|
* @private
|
|
117
117
|
* @type {import("./Source.js").State}
|
package/source/Source.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Source.d.ts","sourceRoot":"","sources":["Source.js"],"names":[],"mappings":";;;;oBAOa,WAAW,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO;;;;;0BAQ3C,CAAS,IAA8C,EAA9C,OAAO,YAAY,EAAE,yBAAyB,KAAG,CAAC,MAAM,GAAC,KAAK,CAAC,MAAM,CAAC,CAAC;;;;;;;;;8BAWhF,MAAM,GAAC,KAAK,CAAC,MAAM,CAAC,GAAC,WAAW;;;;;;;;;;;;;iBAO/B,OAAO,YAAY,EAAE,cAAc;;;;;;;;;;;;;;;AA3BjD;;;GAGG;AAEH;;;;;GAKG;AAEH;;;;;;;;;GASG;AAEH;;;;;;;;;GASG;AAEH;;;;;;;;;GASG;AACH;;;IACE;;OAEG;IACH,qBAFW,OAAO,EAqEjB;IAhEC;;;OAGG;IACH,sBAFU,OAAO,uBAAuB,EAAE,OAAO,GAAC,IAAI,CAEH;IAEnD;;;OAGG;IACH,sBAA4D;IAE5D;;;OAGG;IACH,iCAAuE;IAEvE;;;;OAIG;IACH,SAFU,OAAO,
|
|
1
|
+
{"version":3,"file":"Source.d.ts","sourceRoot":"","sources":["Source.js"],"names":[],"mappings":";;;;oBAOa,WAAW,GAAG,SAAS,GAAG,OA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KAAK,CAKtC;IAED;;OAEG;IACH,YAFY,OAAO,GAAC,SAAS,CAI5B;IAED;;OAEG;IACH,kBAFY,OAAO,CAIlB;IAED;;;OAGG;IACH,gBAEC;IAED;;;;;;OAMG;IACH,8BALW,eAAe,GAAC,SAAS,QAQnC;IAED;;;OAGG;IACH,gBAFW,OAAO,aAAa,EAAE,KAAK,QAKrC;CACF;uBApNsB,cAAc"}
|
package/source/Source.js
CHANGED
|
@@ -75,8 +75,8 @@ class Source extends BaseObject {
|
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* This source is currently loading data. Sources that defer loading to the
|
|
78
|
-
* map's tile queue never set this to `
|
|
79
|
-
* @type {boolean}
|
|
78
|
+
* map's tile queue never set this to a `truthy` value.
|
|
79
|
+
* @type {boolean|number}
|
|
80
80
|
*/
|
|
81
81
|
this.loading = false;
|
|
82
82
|
|
package/source/Vector.d.ts
CHANGED
|
@@ -84,34 +84,30 @@ export type Options<FeatureType extends import("../Feature.js").FeatureLike = im
|
|
|
84
84
|
* import {bbox} from 'ol/loadingstrategy.js';
|
|
85
85
|
*
|
|
86
86
|
* const vectorSource = new Vector({
|
|
87
|
-
*
|
|
88
|
-
* loader: function(extent, resolution, projection, success, failure) {
|
|
89
|
-
* const proj = projection.getCode();
|
|
87
|
+
* loader: async (extent, resolution, projection) => {
|
|
90
88
|
* const url = 'https://ahocevar.com/geoserver/wfs?service=WFS&' +
|
|
91
89
|
* 'version=1.1.0&request=GetFeature&typename=osm:water_areas&' +
|
|
92
|
-
* 'outputFormat=application/json
|
|
93
|
-
* 'bbox=' + extent.join(',') + ',' +
|
|
94
|
-
* const
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* vectorSource.removeLoadedExtent(extent);
|
|
98
|
-
* failure();
|
|
99
|
-
* }
|
|
100
|
-
* xhr.onerror = onError;
|
|
101
|
-
* xhr.onload = function() {
|
|
102
|
-
* if (xhr.status == 200) {
|
|
103
|
-
* const features = vectorSource.getFormat().readFeatures(xhr.responseText);
|
|
104
|
-
* vectorSource.addFeatures(features);
|
|
105
|
-
* success(features);
|
|
106
|
-
* } else {
|
|
107
|
-
* onError();
|
|
90
|
+
* 'outputFormat=application/json' +
|
|
91
|
+
* 'bbox=' + extent.join(',') + ',' + projection.getCode();
|
|
92
|
+
* const response = await fetch(url);
|
|
93
|
+
* if (!response.ok) {
|
|
94
|
+
* throw new Error('Network response was not ok');
|
|
108
95
|
* }
|
|
109
|
-
*
|
|
110
|
-
*
|
|
96
|
+
* const json = await response.json();
|
|
97
|
+
* const features = new GeoJSON().readFeatures(json, {
|
|
98
|
+
* featureProjection: projection,
|
|
99
|
+
* });
|
|
100
|
+
* return features;
|
|
111
101
|
* },
|
|
112
102
|
* strategy: bbox,
|
|
113
103
|
* });
|
|
114
104
|
* ```
|
|
105
|
+
*
|
|
106
|
+
* When you want to retry a failed request, use
|
|
107
|
+
* ```js
|
|
108
|
+
* vectorSource.removeLoadedExtent(extent);
|
|
109
|
+
* vectorSource.changed();
|
|
110
|
+
* ```
|
|
115
111
|
*/
|
|
116
112
|
loader?: import("../featureloader.js").FeatureLoader<FeatureType> | undefined;
|
|
117
113
|
/**
|
|
@@ -204,34 +200,31 @@ import Event from '../events/Event.js';
|
|
|
204
200
|
* import {bbox} from 'ol/loadingstrategy.js';
|
|
205
201
|
*
|
|
206
202
|
* const vectorSource = new Vector({
|
|
207
|
-
*
|
|
208
|
-
* loader: function(extent, resolution, projection, success, failure) {
|
|
209
|
-
* const proj = projection.getCode();
|
|
203
|
+
* loader: async (extent, resolution, projection) => {
|
|
210
204
|
* const url = 'https://ahocevar.com/geoserver/wfs?service=WFS&' +
|
|
211
205
|
* 'version=1.1.0&request=GetFeature&typename=osm:water_areas&' +
|
|
212
|
-
* 'outputFormat=application/json
|
|
213
|
-
* 'bbox=' + extent.join(',') + ',' +
|
|
214
|
-
* const
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
* vectorSource.removeLoadedExtent(extent);
|
|
218
|
-
* failure();
|
|
206
|
+
* 'outputFormat=application/json' +
|
|
207
|
+
* 'bbox=' + extent.join(',') + ',' + projection.getCode();
|
|
208
|
+
* const response = await fetch(url);
|
|
209
|
+
* if (!response.ok) {
|
|
210
|
+
* throw new Error('Network response was not ok');
|
|
219
211
|
* }
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
* success(features);
|
|
226
|
-
* } else {
|
|
227
|
-
* onError();
|
|
228
|
-
* }
|
|
229
|
-
* }
|
|
230
|
-
* xhr.send();
|
|
212
|
+
* const json = await response.json();
|
|
213
|
+
* const features = new GeoJSON().readFeatures(json, {
|
|
214
|
+
* featureProjection: projection,
|
|
215
|
+
* });
|
|
216
|
+
* return features;
|
|
231
217
|
* },
|
|
232
218
|
* strategy: bbox,
|
|
233
219
|
* });
|
|
234
220
|
* ```
|
|
221
|
+
*
|
|
222
|
+
* When you want to retry a failed request, use
|
|
223
|
+
* ```js
|
|
224
|
+
* vectorSource.removeLoadedExtent(extent);
|
|
225
|
+
* vectorSource.changed();
|
|
226
|
+
* ```
|
|
227
|
+
*
|
|
235
228
|
* @property {boolean} [overlaps=true] This source may have overlapping geometries.
|
|
236
229
|
* Setting this to `false` (e.g. for sources with polygons that represent administrative
|
|
237
230
|
* boundaries or TopoJSON sources) allows the renderer to optimise fill and
|
|
@@ -337,11 +330,6 @@ declare class VectorSource<FeatureType extends import("../Feature.js").FeatureLi
|
|
|
337
330
|
* @type {RBush<{extent: import("../extent.js").Extent}>}
|
|
338
331
|
*/
|
|
339
332
|
private loadedExtentsRtree_;
|
|
340
|
-
/**
|
|
341
|
-
* @type {number}
|
|
342
|
-
* @private
|
|
343
|
-
*/
|
|
344
|
-
private loadingExtentsCount_;
|
|
345
333
|
/**
|
|
346
334
|
* @private
|
|
347
335
|
* @type {!Object<string, FeatureType>}
|
package/source/Vector.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,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
package/source/Vector.js
CHANGED
|
@@ -99,34 +99,31 @@ export class VectorSourceEvent extends Event {
|
|
|
99
99
|
* import {bbox} from 'ol/loadingstrategy.js';
|
|
100
100
|
*
|
|
101
101
|
* const vectorSource = new Vector({
|
|
102
|
-
*
|
|
103
|
-
* loader: function(extent, resolution, projection, success, failure) {
|
|
104
|
-
* const proj = projection.getCode();
|
|
102
|
+
* loader: async (extent, resolution, projection) => {
|
|
105
103
|
* const url = 'https://ahocevar.com/geoserver/wfs?service=WFS&' +
|
|
106
104
|
* 'version=1.1.0&request=GetFeature&typename=osm:water_areas&' +
|
|
107
|
-
* 'outputFormat=application/json
|
|
108
|
-
* 'bbox=' + extent.join(',') + ',' +
|
|
109
|
-
* const
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* vectorSource.removeLoadedExtent(extent);
|
|
113
|
-
* failure();
|
|
105
|
+
* 'outputFormat=application/json' +
|
|
106
|
+
* 'bbox=' + extent.join(',') + ',' + projection.getCode();
|
|
107
|
+
* const response = await fetch(url);
|
|
108
|
+
* if (!response.ok) {
|
|
109
|
+
* throw new Error('Network response was not ok');
|
|
114
110
|
* }
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
* success(features);
|
|
121
|
-
* } else {
|
|
122
|
-
* onError();
|
|
123
|
-
* }
|
|
124
|
-
* }
|
|
125
|
-
* xhr.send();
|
|
111
|
+
* const json = await response.json();
|
|
112
|
+
* const features = new GeoJSON().readFeatures(json, {
|
|
113
|
+
* featureProjection: projection,
|
|
114
|
+
* });
|
|
115
|
+
* return features;
|
|
126
116
|
* },
|
|
127
117
|
* strategy: bbox,
|
|
128
118
|
* });
|
|
129
119
|
* ```
|
|
120
|
+
*
|
|
121
|
+
* When you want to retry a failed request, use
|
|
122
|
+
* ```js
|
|
123
|
+
* vectorSource.removeLoadedExtent(extent);
|
|
124
|
+
* vectorSource.changed();
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
130
127
|
* @property {boolean} [overlaps=true] This source may have overlapping geometries.
|
|
131
128
|
* Setting this to `false` (e.g. for sources with polygons that represent administrative
|
|
132
129
|
* boundaries or TopoJSON sources) allows the renderer to optimise fill and
|
|
@@ -263,12 +260,6 @@ class VectorSource extends Source {
|
|
|
263
260
|
*/
|
|
264
261
|
this.loadedExtentsRtree_ = new RBush();
|
|
265
262
|
|
|
266
|
-
/**
|
|
267
|
-
* @type {number}
|
|
268
|
-
* @private
|
|
269
|
-
*/
|
|
270
|
-
this.loadingExtentsCount_ = 0;
|
|
271
|
-
|
|
272
263
|
/**
|
|
273
264
|
* @private
|
|
274
265
|
* @type {!Object<string, FeatureType>}
|
|
@@ -1006,40 +997,59 @@ class VectorSource extends Source {
|
|
|
1006
997
|
},
|
|
1007
998
|
);
|
|
1008
999
|
if (!alreadyLoaded) {
|
|
1009
|
-
|
|
1000
|
+
this.loading = Number(this.loading) + 1;
|
|
1010
1001
|
this.dispatchEvent(
|
|
1011
1002
|
new VectorSourceEvent(VectorEventType.FEATURESLOADSTART),
|
|
1012
1003
|
);
|
|
1013
|
-
|
|
1004
|
+
|
|
1005
|
+
/**
|
|
1006
|
+
* @param {Array<FeatureType>} features Loaded features
|
|
1007
|
+
*/
|
|
1008
|
+
const success = (features) => {
|
|
1009
|
+
this.loading = Number(this.loading) - 1;
|
|
1010
|
+
this.dispatchEvent(
|
|
1011
|
+
new VectorSourceEvent(
|
|
1012
|
+
VectorEventType.FEATURESLOADEND,
|
|
1013
|
+
undefined,
|
|
1014
|
+
features,
|
|
1015
|
+
),
|
|
1016
|
+
);
|
|
1017
|
+
};
|
|
1018
|
+
|
|
1019
|
+
const failure = () => {
|
|
1020
|
+
this.changed();
|
|
1021
|
+
this.loading = Number(this.loading) - 1;
|
|
1022
|
+
this.dispatchEvent(
|
|
1023
|
+
new VectorSourceEvent(VectorEventType.FEATURESLOADERROR),
|
|
1024
|
+
);
|
|
1025
|
+
};
|
|
1026
|
+
|
|
1027
|
+
//TODO Remove this when the deprecatedsuccess and failure arguments are removed
|
|
1028
|
+
let disableCallbacks = false;
|
|
1029
|
+
|
|
1030
|
+
const loaded = this.loader_.call(
|
|
1014
1031
|
this,
|
|
1015
1032
|
extentToLoad,
|
|
1016
1033
|
resolution,
|
|
1017
1034
|
projection,
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
*/
|
|
1021
|
-
(features) => {
|
|
1022
|
-
--this.loadingExtentsCount_;
|
|
1023
|
-
this.dispatchEvent(
|
|
1024
|
-
new VectorSourceEvent(
|
|
1025
|
-
VectorEventType.FEATURESLOADEND,
|
|
1026
|
-
undefined,
|
|
1027
|
-
features,
|
|
1028
|
-
),
|
|
1029
|
-
);
|
|
1030
|
-
},
|
|
1031
|
-
() => {
|
|
1032
|
-
--this.loadingExtentsCount_;
|
|
1033
|
-
this.dispatchEvent(
|
|
1034
|
-
new VectorSourceEvent(VectorEventType.FEATURESLOADERROR),
|
|
1035
|
-
);
|
|
1036
|
-
},
|
|
1035
|
+
(features) => disableCallbacks || success(features),
|
|
1036
|
+
() => disableCallbacks || failure(),
|
|
1037
1037
|
);
|
|
1038
|
+
if (loaded instanceof Promise) {
|
|
1039
|
+
//TODO Remove this when the deprecatedsuccess and failure arguments are removed
|
|
1040
|
+
disableCallbacks = true;
|
|
1041
|
+
loaded
|
|
1042
|
+
.then((features) => {
|
|
1043
|
+
this.addFeatures(features);
|
|
1044
|
+
success(features);
|
|
1045
|
+
})
|
|
1046
|
+
.catch(failure);
|
|
1047
|
+
} else if (this.loader_.length < 4) {
|
|
1048
|
+
this.loading = false;
|
|
1049
|
+
}
|
|
1038
1050
|
loadedExtentsRtree.insert(extentToLoad, {extent: extentToLoad.slice()});
|
|
1039
1051
|
}
|
|
1040
1052
|
}
|
|
1041
|
-
this.loading =
|
|
1042
|
-
this.loader_.length < 4 ? false : this.loadingExtentsCount_ > 0;
|
|
1043
1053
|
}
|
|
1044
1054
|
|
|
1045
1055
|
/**
|
package/util.js
CHANGED