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,14 @@
|
||||
import Map from '../src/ol/Map.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import MVT from '../src/ol/format/MVT.js';
|
||||
import VectorTileLayer from '../src/ol/layer/VectorTile.js';
|
||||
import {get as getProjection} from '../src/ol/proj.js';
|
||||
import VectorTileSource from '../src/ol/source/VectorTile.js';
|
||||
import {Fill, Icon, Stroke, Style, Text} from '../src/ol/style.js';
|
||||
import Map from '../src/ol/Map.js';
|
||||
import TileGrid from '../src/ol/tilegrid/TileGrid.js';
|
||||
import VectorTileLayer from '../src/ol/layer/VectorTile.js';
|
||||
import VectorTileSource from '../src/ol/source/VectorTile.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import {Fill, Icon, Stroke, Style, Text} from '../src/ol/style.js';
|
||||
import {get as getProjection} from '../src/ol/proj.js';
|
||||
|
||||
|
||||
const key = 'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q';
|
||||
const key =
|
||||
'pk.eyJ1IjoiYWhvY2V2YXIiLCJhIjoiY2pzbmg0Nmk5MGF5NzQzbzRnbDNoeHJrbiJ9.7_-_gL8ur7ZtEiNwRfCy7Q';
|
||||
|
||||
// Calculation of resolutions that match zoom levels 1, 3, 5, 7, 9, 11, 13, 15.
|
||||
const resolutions = [];
|
||||
@@ -17,37 +17,43 @@ for (let i = 0; i <= 8; ++i) {
|
||||
}
|
||||
// Calculation of tile urls for zoom levels 1, 3, 5, 7, 9, 11, 13, 15.
|
||||
function tileUrlFunction(tileCoord) {
|
||||
return ('https://{a-d}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/' +
|
||||
'{z}/{x}/{y}.vector.pbf?access_token=' + key)
|
||||
return (
|
||||
'https://{a-d}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/' +
|
||||
'{z}/{x}/{y}.vector.pbf?access_token=' +
|
||||
key
|
||||
)
|
||||
.replace('{z}', String(tileCoord[0] * 2 - 1))
|
||||
.replace('{x}', String(tileCoord[1]))
|
||||
.replace('{y}', String(tileCoord[2]))
|
||||
.replace('{a-d}', 'abcd'.substr(
|
||||
((tileCoord[1] << tileCoord[0]) + tileCoord[2]) % 4, 1));
|
||||
.replace(
|
||||
'{a-d}',
|
||||
'abcd'.substr(((tileCoord[1] << tileCoord[0]) + tileCoord[2]) % 4, 1)
|
||||
);
|
||||
}
|
||||
|
||||
const map = new Map({
|
||||
layers: [
|
||||
new VectorTileLayer({
|
||||
source: new VectorTileSource({
|
||||
attributions: '© <a href="https://www.mapbox.com/map-feedback/">Mapbox</a> ' +
|
||||
attributions:
|
||||
'© <a href="https://www.mapbox.com/map-feedback/">Mapbox</a> ' +
|
||||
'© <a href="https://www.openstreetmap.org/copyright">' +
|
||||
'OpenStreetMap contributors</a>',
|
||||
format: new MVT(),
|
||||
tileGrid: new TileGrid({
|
||||
extent: getProjection('EPSG:3857').getExtent(),
|
||||
resolutions: resolutions,
|
||||
tileSize: 512
|
||||
tileSize: 512,
|
||||
}),
|
||||
tileUrlFunction: tileUrlFunction
|
||||
tileUrlFunction: tileUrlFunction,
|
||||
}),
|
||||
style: createMapboxStreetsV6Style(Style, Fill, Stroke, Icon, Text)
|
||||
})
|
||||
style: createMapboxStreetsV6Style(Style, Fill, Stroke, Icon, Text),
|
||||
}),
|
||||
],
|
||||
target: 'map',
|
||||
view: new View({
|
||||
center: [0, 0],
|
||||
minZoom: 1,
|
||||
zoom: 2
|
||||
})
|
||||
zoom: 2,
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user