Files
openlayers/rendering/cases/stacking/main.js
Tim Schaub 054af09032 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.
2020-04-06 12:54:09 -06:00

89 lines
1.7 KiB
JavaScript

/**
* Demonstrate stacking with z-index. Layers and controls
* can be ordered with z-index, but controls always appear
* above layers.
*/
import Control from '../../../src/ol/control/Control.js';
import Layer from '../../../src/ol/layer/Layer.js';
import Map from '../../../src/ol/Map.js';
import SourceState from '../../../src/ol/source/State.js';
import View from '../../../src/ol/View.js';
class Element extends Layer {
constructor(options, style) {
super(options);
const element = document.createElement('div');
element.style.position = 'absolute';
Object.assign(element.style, style);
this.element = element;
}
getSourceState() {
return SourceState.READY;
}
render() {
return this.element;
}
}
// elements for stacked controls
const element1 = document.createElement('div');
const style1 = element1.style;
style1.position = 'absolute';
style1.background = 'blue';
style1.width = '25%';
style1.height = '50%';
style1.zIndex = '1';
const element2 = document.createElement('div');
const style2 = element2.style;
style2.position = 'absolute';
style2.background = 'orange';
style2.width = '75%';
style2.height = '25%';
style2.zIndex = '-1';
new Map({
target: 'map',
layers: [
new Element(
{
zIndex: 200,
},
{
background: 'red',
width: '50%',
height: '100%',
}
),
new Element(
{
zIndex: -200,
},
{
background: 'green',
width: '100%',
height: '50%',
}
),
],
controls: [
new Control({
element: element1,
}),
new Control({
element: element2,
}),
],
view: new View({
center: [0, 0],
zoom: 0,
}),
});
render();