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,79 +1,81 @@
|
||||
import Feature from '../src/ol/Feature.js';
|
||||
import Map from '../src/ol/Map.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import LineString from '../src/ol/geom/LineString.js';
|
||||
import {Tile as TileLayer, Vector as VectorLayer} from '../src/ol/layer.js';
|
||||
import Map from '../src/ol/Map.js';
|
||||
import Stamen from '../src/ol/source/Stamen.js';
|
||||
import VectorSource from '../src/ol/source/Vector.js';
|
||||
import View from '../src/ol/View.js';
|
||||
import {Stroke, Style} from '../src/ol/style.js';
|
||||
import {Tile as TileLayer, Vector as VectorLayer} from '../src/ol/layer.js';
|
||||
import {getVectorContext} from '../src/ol/render.js';
|
||||
|
||||
const tileLayer = new TileLayer({
|
||||
source: new Stamen({
|
||||
layer: 'toner'
|
||||
})
|
||||
layer: 'toner',
|
||||
}),
|
||||
});
|
||||
|
||||
const map = new Map({
|
||||
layers: [
|
||||
tileLayer
|
||||
],
|
||||
layers: [tileLayer],
|
||||
target: 'map',
|
||||
view: new View({
|
||||
center: [0, 0],
|
||||
zoom: 2
|
||||
})
|
||||
zoom: 2,
|
||||
}),
|
||||
});
|
||||
|
||||
const style = new Style({
|
||||
stroke: new Stroke({
|
||||
color: '#EAE911',
|
||||
width: 2
|
||||
})
|
||||
width: 2,
|
||||
}),
|
||||
});
|
||||
|
||||
const flightsSource = new VectorSource({
|
||||
wrapX: false,
|
||||
attributions: 'Flight data by ' +
|
||||
'<a href="http://openflights.org/data.html">OpenFlights</a>,',
|
||||
loader: function() {
|
||||
attributions:
|
||||
'Flight data by ' +
|
||||
'<a href="http://openflights.org/data.html">OpenFlights</a>,',
|
||||
loader: function () {
|
||||
const url = 'data/openflights/flights.json';
|
||||
fetch(url).then(function(response) {
|
||||
return response.json();
|
||||
}).then(function(json) {
|
||||
const flightsData = json.flights;
|
||||
for (let i = 0; i < flightsData.length; i++) {
|
||||
const flight = flightsData[i];
|
||||
const from = flight[0];
|
||||
const to = flight[1];
|
||||
fetch(url)
|
||||
.then(function (response) {
|
||||
return response.json();
|
||||
})
|
||||
.then(function (json) {
|
||||
const flightsData = json.flights;
|
||||
for (let i = 0; i < flightsData.length; i++) {
|
||||
const flight = flightsData[i];
|
||||
const from = flight[0];
|
||||
const to = flight[1];
|
||||
|
||||
// create an arc circle between the two locations
|
||||
const arcGenerator = new arc.GreatCircle(
|
||||
{x: from[1], y: from[0]},
|
||||
{x: to[1], y: to[0]});
|
||||
// create an arc circle between the two locations
|
||||
const arcGenerator = new arc.GreatCircle(
|
||||
{x: from[1], y: from[0]},
|
||||
{x: to[1], y: to[0]}
|
||||
);
|
||||
|
||||
const arcLine = arcGenerator.Arc(100, {offset: 10});
|
||||
if (arcLine.geometries.length === 1) {
|
||||
const line = new LineString(arcLine.geometries[0].coords);
|
||||
line.transform('EPSG:4326', 'EPSG:3857');
|
||||
const arcLine = arcGenerator.Arc(100, {offset: 10});
|
||||
if (arcLine.geometries.length === 1) {
|
||||
const line = new LineString(arcLine.geometries[0].coords);
|
||||
line.transform('EPSG:4326', 'EPSG:3857');
|
||||
|
||||
const feature = new Feature({
|
||||
geometry: line,
|
||||
finished: false
|
||||
});
|
||||
// add the feature with a delay so that the animation
|
||||
// for all features does not start at the same time
|
||||
addLater(feature, i * 50);
|
||||
const feature = new Feature({
|
||||
geometry: line,
|
||||
finished: false,
|
||||
});
|
||||
// add the feature with a delay so that the animation
|
||||
// for all features does not start at the same time
|
||||
addLater(feature, i * 50);
|
||||
}
|
||||
}
|
||||
}
|
||||
tileLayer.on('postrender', animateFlights);
|
||||
});
|
||||
}
|
||||
tileLayer.on('postrender', animateFlights);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const flightsLayer = new VectorLayer({
|
||||
source: flightsSource,
|
||||
style: function(feature) {
|
||||
style: function (feature) {
|
||||
// if the animation is still active for a feature, do not
|
||||
// render the feature with the layer style
|
||||
if (feature.get('finished')) {
|
||||
@@ -81,7 +83,7 @@ const flightsLayer = new VectorLayer({
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
map.addLayer(flightsLayer);
|
||||
@@ -117,7 +119,7 @@ function animateFlights(event) {
|
||||
}
|
||||
|
||||
function addLater(feature, timeout) {
|
||||
window.setTimeout(function() {
|
||||
window.setTimeout(function () {
|
||||
feature.set('start', new Date().getTime());
|
||||
flightsSource.addFeature(feature);
|
||||
}, timeout);
|
||||
|
||||
Reference in New Issue
Block a user