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:
@@ -2,9 +2,9 @@
|
||||
* @module ol/source/CartoDB
|
||||
*/
|
||||
|
||||
import {assign} from '../obj.js';
|
||||
import SourceState from './State.js';
|
||||
import XYZ from './XYZ.js';
|
||||
import {assign} from '../obj.js';
|
||||
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
@@ -29,7 +29,6 @@ import XYZ from './XYZ.js';
|
||||
* @property {string} account If using named maps, this will be the name of the template to load.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {Object} CartoDBLayerInfo
|
||||
* @property {string} layergroupid The layer group ID
|
||||
@@ -53,7 +52,7 @@ class CartoDB extends XYZ {
|
||||
maxZoom: options.maxZoom !== undefined ? options.maxZoom : 18,
|
||||
minZoom: options.minZoom,
|
||||
projection: options.projection,
|
||||
wrapX: options.wrapX
|
||||
wrapX: options.wrapX,
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -132,7 +131,10 @@ class CartoDB extends XYZ {
|
||||
}
|
||||
|
||||
const client = new XMLHttpRequest();
|
||||
client.addEventListener('load', this.handleInitResponse_.bind(this, paramHash));
|
||||
client.addEventListener(
|
||||
'load',
|
||||
this.handleInitResponse_.bind(this, paramHash)
|
||||
);
|
||||
client.addEventListener('error', this.handleInitError_.bind(this));
|
||||
client.open('POST', mapUrl);
|
||||
client.setRequestHeader('Content-type', 'application/json');
|
||||
@@ -149,10 +151,12 @@ class CartoDB extends XYZ {
|
||||
handleInitResponse_(paramHash, event) {
|
||||
const client = /** @type {XMLHttpRequest} */ (event.target);
|
||||
// status will be 0 for file:// urls
|
||||
if (!client.status || client.status >= 200 && client.status < 300) {
|
||||
if (!client.status || (client.status >= 200 && client.status < 300)) {
|
||||
let response;
|
||||
try {
|
||||
response = /** @type {CartoDBLayerInfo} */(JSON.parse(client.responseText));
|
||||
response = /** @type {CartoDBLayerInfo} */ (JSON.parse(
|
||||
client.responseText
|
||||
));
|
||||
} catch (err) {
|
||||
this.setState(SourceState.ERROR);
|
||||
return;
|
||||
@@ -179,11 +183,16 @@ class CartoDB extends XYZ {
|
||||
* @private
|
||||
*/
|
||||
applyTemplate_(data) {
|
||||
const tilesUrl = 'https://' + data.cdn_url.https + '/' + this.account_ +
|
||||
'/api/v1/map/' + data.layergroupid + '/{z}/{x}/{y}.png';
|
||||
const tilesUrl =
|
||||
'https://' +
|
||||
data.cdn_url.https +
|
||||
'/' +
|
||||
this.account_ +
|
||||
'/api/v1/map/' +
|
||||
data.layergroupid +
|
||||
'/{z}/{x}/{y}.png';
|
||||
this.setUrl(tilesUrl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default CartoDB;
|
||||
|
||||
Reference in New Issue
Block a user