Make code prettier
This updates ESLint and our shared eslint-config-openlayers to use Prettier. Most formatting changes were automatically applied with this:
npm run lint -- --fix
A few manual changes were required:
* In `examples/offscreen-canvas.js`, the `//eslint-disable-line` comment needed to be moved to the appropriate line to disable the error about the `'worker-loader!./offscreen-canvas.worker.js'` import.
* In `examples/webpack/exapmle-builder.js`, spaces could not be added after a couple `function`s for some reason. While editing this, I reworked `ExampleBuilder` to be a class.
* In `src/ol/format/WMSGetFeatureInfo.js`, the `// @ts-ignore` comment needed to be moved down one line so it applied to the `parsersNS` argument.
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
import Map from '../src/ol/Map.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import {Image as ImageLayer, Tile as TileLayer} from '../src/ol/layer.js';
|
||||
import {fromLonLat} from '../src/ol/proj.js';
|
||||
import {Raster as RasterSource, TileJSON} from '../src/ol/source.js';
|
||||
import XYZ from '../src/ol/source/XYZ.js';
|
||||
import {Image as ImageLayer, Tile as TileLayer} from '../src/ol/layer.js';
|
||||
import {Raster as RasterSource, TileJSON} from '../src/ol/source.js';
|
||||
import {fromLonLat} from '../src/ol/proj.js';
|
||||
|
||||
function flood(pixels, data) {
|
||||
const pixel = pixels[0];
|
||||
if (pixel[3]) {
|
||||
const height = -10000 + ((pixel[0] * 256 * 256 + pixel[1] * 256 + pixel[2]) * 0.1);
|
||||
const height =
|
||||
-10000 + (pixel[0] * 256 * 256 + pixel[1] * 256 + pixel[2]) * 0.1;
|
||||
if (height <= data.level) {
|
||||
pixel[0] = 145;
|
||||
pixel[1] = 175;
|
||||
@@ -21,21 +22,24 @@ function flood(pixels, data) {
|
||||
return pixel;
|
||||
}
|
||||
|
||||
const key = 'pk.eyJ1IjoidHNjaGF1YiIsImEiOiJjaW5zYW5lNHkxMTNmdWttM3JyOHZtMmNtIn0.CDIBD8H-G2Gf-cPkIuWtRg';
|
||||
const key =
|
||||
'pk.eyJ1IjoidHNjaGF1YiIsImEiOiJjaW5zYW5lNHkxMTNmdWttM3JyOHZtMmNtIn0.CDIBD8H-G2Gf-cPkIuWtRg';
|
||||
const elevation = new TileLayer({
|
||||
source: new XYZ({
|
||||
url: 'https://api.mapbox.com/v4/mapbox.terrain-rgb/{z}/{x}/{y}.pngraw?access_token=' + key,
|
||||
crossOrigin: 'anonymous'
|
||||
})
|
||||
url:
|
||||
'https://api.mapbox.com/v4/mapbox.terrain-rgb/{z}/{x}/{y}.pngraw?access_token=' +
|
||||
key,
|
||||
crossOrigin: 'anonymous',
|
||||
}),
|
||||
});
|
||||
elevation.on('prerender', function(evt) {
|
||||
elevation.on('prerender', function (evt) {
|
||||
evt.context.imageSmoothingEnabled = false;
|
||||
evt.context.msImageSmoothingEnabled = false;
|
||||
});
|
||||
|
||||
const raster = new RasterSource({
|
||||
sources: [elevation],
|
||||
operation: flood
|
||||
operation: flood,
|
||||
});
|
||||
|
||||
const map = new Map({
|
||||
@@ -43,30 +47,32 @@ const map = new Map({
|
||||
layers: [
|
||||
new TileLayer({
|
||||
source: new TileJSON({
|
||||
url: 'https://api.tiles.mapbox.com/v4/mapbox.world-light.json?secure&access_token=' + key,
|
||||
crossOrigin: 'anonymous'
|
||||
})
|
||||
url:
|
||||
'https://api.tiles.mapbox.com/v4/mapbox.world-light.json?secure&access_token=' +
|
||||
key,
|
||||
crossOrigin: 'anonymous',
|
||||
}),
|
||||
}),
|
||||
new ImageLayer({
|
||||
opacity: 0.6,
|
||||
source: raster
|
||||
})
|
||||
source: raster,
|
||||
}),
|
||||
],
|
||||
view: new View({
|
||||
center: fromLonLat([-122.3267, 37.8377]),
|
||||
zoom: 11
|
||||
})
|
||||
zoom: 11,
|
||||
}),
|
||||
});
|
||||
|
||||
const control = document.getElementById('level');
|
||||
const output = document.getElementById('output');
|
||||
control.addEventListener('input', function() {
|
||||
control.addEventListener('input', function () {
|
||||
output.innerText = control.value;
|
||||
raster.changed();
|
||||
});
|
||||
output.innerText = control.value;
|
||||
|
||||
raster.on('beforeoperations', function(event) {
|
||||
raster.on('beforeoperations', function (event) {
|
||||
event.data.level = control.value;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user