Merge pull request #10097 from fredj/text-align

Align layer canvas to the left
This commit is contained in:
Frédéric Junod
2019-10-10 08:31:36 +02:00
committed by GitHub
6 changed files with 53 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

View File

@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<style>
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
#map {
width: 100%;
height: 100%;
text-align: right;
}
.ol-control {
display: none;
}
</style>
</head>
<body>
<div id="map"></div>
<script src="main.js"></script>
</body>
</script>
</html>

View File

@@ -0,0 +1,24 @@
import Map from '../../../src/ol/Map.js';
import View from '../../../src/ol/View.js';
import TileLayer from '../../../src/ol/layer/Tile.js';
import {fromLonLat} from '../../../src/ol/proj.js';
import XYZ from '../../../src/ol/source/XYZ.js';
new Map({
layers: [
new TileLayer({
source: new XYZ({
url: '/data/tiles/satellite/{z}/{x}/{y}.jpg'
})
})
],
target: 'map',
view: new View({
rotation: Math.PI / 3,
center: fromLonLat([8.6, 50.1]),
zoom: 3
})
});
render();

View File

@@ -109,6 +109,7 @@ class CanvasLayerRenderer extends LayerRenderer {
container.appendChild(canvas);
style = canvas.style;
style.position = 'absolute';
style.left = '0';
style.transformOrigin = 'top left';
this.container = container;
this.context = context;

View File

@@ -138,6 +138,7 @@ class CanvasVectorTileLayerRenderer extends CanvasTileLayerRenderer {
const overlayContext = createCanvasContext2D();
const style = overlayContext.canvas.style;
style.position = 'absolute';
style.left = '0';
style.transformOrigin = 'top left';
this.overlayContext_ = overlayContext;
this.overlayContextUid_ = getUid(overlayContext);

View File

@@ -247,6 +247,7 @@ class WebGLHelper extends Disposable {
*/
this.canvas_ = document.createElement('canvas');
this.canvas_.style.position = 'absolute';
this.canvas_.style.left = '0';
/**