Merge pull request #12785 from mike-000/Promise.allSettled
Promise.allSettled polyfill and other browser compatibilty
This commit is contained in:
@@ -102,6 +102,8 @@ For older browsers and platforms (Internet Explorer, Android 4.x, iOS v12 and ol
|
|||||||
* [`Number.isInteger`](https://caniuse.com/isInteger): Available from [polyfill.io](https://polyfill.io/).
|
* [`Number.isInteger`](https://caniuse.com/isInteger): Available from [polyfill.io](https://polyfill.io/).
|
||||||
* [Pointer events](https://caniuse.com/pointer): Use [elm-pep](https://npmjs.com/package/elm-pep) (lightweight) or [pepjs](https://npmjs.com/package/pepjs) (for really, really old browsers).
|
* [Pointer events](https://caniuse.com/pointer): Use [elm-pep](https://npmjs.com/package/elm-pep) (lightweight) or [pepjs](https://npmjs.com/package/pepjs) (for really, really old browsers).
|
||||||
|
|
||||||
|
[`ol/source/GeoTIFF`](https://openlayers.org/en/latest/apidoc/module-ol_source_GeoTIFF-GeoTIFFSource.html) requires a browser that supports [ECMAScript 6](https://262.ecma-international.org/6.0/). Additionally a polyfill for [`Promise.allSettled`](https://caniuse.com/mdn-javascript_builtins_promise_allsettled) may be needed.
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
Check out the [hosted examples](https://openlayers.org/en/latest/examples/), the [workshop](https://openlayers.org/workshop/) or the [API documentation](https://openlayers.org/en/latest/apidoc/).
|
Check out the [hosted examples](https://openlayers.org/en/latest/examples/), the [workshop](https://openlayers.org/workshop/) or the [API documentation](https://openlayers.org/en/latest/apidoc/).
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
"jsts": false,
|
"jsts": false,
|
||||||
"JSZip": false,
|
"JSZip": false,
|
||||||
"mapboxgl": false,
|
"mapboxgl": false,
|
||||||
|
"NumpyLoader": false,
|
||||||
"saveAs": false,
|
"saveAs": false,
|
||||||
"toastr": false,
|
"toastr": false,
|
||||||
"topojson": false,
|
"topojson": false,
|
||||||
|
|||||||
+10
-7
@@ -1,8 +1,7 @@
|
|||||||
|
import DataTileSource from '../src/ol/source/DataTile.js';
|
||||||
import Map from '../src/ol/Map.js';
|
import Map from '../src/ol/Map.js';
|
||||||
import TileLayer from '../src/ol/layer/WebGLTile.js';
|
import TileLayer from '../src/ol/layer/WebGLTile.js';
|
||||||
import View from '../src/ol/View.js';
|
import View from '../src/ol/View.js';
|
||||||
|
|
||||||
import DataTileSource from '../src/ol/source/DataTile.js';
|
|
||||||
import {fromLonLat} from '../src/ol/proj.js';
|
import {fromLonLat} from '../src/ol/proj.js';
|
||||||
|
|
||||||
// 16-bit COG
|
// 16-bit COG
|
||||||
@@ -17,7 +16,7 @@ function numpyTileLoader(z, x, y) {
|
|||||||
|
|
||||||
return fetch(url)
|
return fetch(url)
|
||||||
.then((r) => r.arrayBuffer())
|
.then((r) => r.arrayBuffer())
|
||||||
.then((buffer) => NumpyLoader.fromArrayBuffer(buffer)) // eslint-disable-line no-undef
|
.then((buffer) => NumpyLoader.fromArrayBuffer(buffer))
|
||||||
.then((numpyData) => {
|
.then((numpyData) => {
|
||||||
// flatten the numpy data
|
// flatten the numpy data
|
||||||
const dataTile = new Float32Array(256 * 256 * 5);
|
const dataTile = new Float32Array(256 * 256 * 5);
|
||||||
@@ -84,21 +83,25 @@ const inputMax = document.getElementById('input-max');
|
|||||||
const outputMin = document.getElementById('output-min');
|
const outputMin = document.getElementById('output-min');
|
||||||
const outputMax = document.getElementById('output-max');
|
const outputMax = document.getElementById('output-max');
|
||||||
|
|
||||||
inputMin.addEventListener('input', (evt) => {
|
const handleMin = (evt) => {
|
||||||
numpyLayer.updateStyleVariables({
|
numpyLayer.updateStyleVariables({
|
||||||
'bMin': parseFloat(evt.target.value),
|
'bMin': parseFloat(evt.target.value),
|
||||||
'bMax': parseFloat(inputMax.value),
|
'bMax': parseFloat(inputMax.value),
|
||||||
});
|
});
|
||||||
outputMin.innerText = evt.target.value;
|
outputMin.innerText = evt.target.value;
|
||||||
});
|
};
|
||||||
|
inputMin.addEventListener('input', handleMin);
|
||||||
|
inputMin.addEventListener('change', handleMin);
|
||||||
|
|
||||||
inputMax.addEventListener('input', (evt) => {
|
const handleMax = (evt) => {
|
||||||
numpyLayer.updateStyleVariables({
|
numpyLayer.updateStyleVariables({
|
||||||
'bMin': parseFloat(inputMin.value),
|
'bMin': parseFloat(inputMin.value),
|
||||||
'bMax': parseFloat(evt.target.value),
|
'bMax': parseFloat(evt.target.value),
|
||||||
});
|
});
|
||||||
outputMax.innerText = evt.target.value;
|
outputMax.innerText = evt.target.value;
|
||||||
});
|
};
|
||||||
|
inputMax.addEventListener('input', handleMax);
|
||||||
|
inputMax.addEventListener('change', handleMax);
|
||||||
|
|
||||||
inputMin.value = initialMin;
|
inputMin.value = initialMin;
|
||||||
inputMax.value = initialMax;
|
inputMax.value = initialMax;
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
if (typeof Promise !== 'undefined' && !Promise.allSettled && Array.from) {
|
||||||
|
Promise.allSettled =
|
||||||
|
function (promises) {
|
||||||
|
return Promise.all(
|
||||||
|
Array.from(
|
||||||
|
promises,
|
||||||
|
function (p) {
|
||||||
|
return p.then (
|
||||||
|
function (value) {
|
||||||
|
return {status: 'fulfilled', value: value};
|
||||||
|
}
|
||||||
|
).catch(
|
||||||
|
function (reason) {
|
||||||
|
return {status: 'rejected', reason: reason};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -69,6 +69,7 @@
|
|||||||
<link rel="stylesheet" href="./resources/layout.css" type="text/css">
|
<link rel="stylesheet" href="./resources/layout.css" type="text/css">
|
||||||
<script src="https://unpkg.com/elm-pep"></script>
|
<script src="https://unpkg.com/elm-pep"></script>
|
||||||
<script src="https://cdn.polyfill.io/v3/polyfill.min.js?features=fetch,requestAnimationFrame,Element.prototype.classList,URL,TextDecoder,Number.isInteger"></script>
|
<script src="https://cdn.polyfill.io/v3/polyfill.min.js?features=fetch,requestAnimationFrame,Element.prototype.classList,URL,TextDecoder,Number.isInteger"></script>
|
||||||
|
<script src="./resources/Promise.allSettled.js"></script>
|
||||||
{{{ extraHead.local }}}
|
{{{ extraHead.local }}}
|
||||||
{{{ css.tag }}}
|
{{{ css.tag }}}
|
||||||
<title>{{ title }}</title>
|
<title>{{ title }}</title>
|
||||||
|
|||||||
Reference in New Issue
Block a user