Skip to content

Commit bc15ba4

Browse files
committed
Fix the offset issue in HtmlLayer when the container has a height setting.
1 parent e810a4a commit bc15ba4

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/modules/layer/type/HtmlLayer.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import { Cesium } from '../../../libs'
66
import State from '../../state/State'
7-
import { DomUtil } from '../../utils'
7+
import { Util, DomUtil } from '../../utils'
88
import { Transform } from '../../transform'
99
import Layer from '../Layer'
1010

@@ -13,6 +13,15 @@ class HtmlLayer extends Layer {
1313
super(id)
1414
this._delegate = DomUtil.create('div', 'html-layer', undefined)
1515
this._delegate.setAttribute('id', this._id)
16+
Util.merge(this._delegate.style, {
17+
position: 'absolute',
18+
left: '0',
19+
top: '0',
20+
width: '100%',
21+
height: '100%',
22+
pointerEvents: 'none',
23+
})
24+
1625
this._renderRemoveCallback = undefined
1726
this._state = State.INITIALIZED
1827
}
@@ -45,7 +54,7 @@ class HtmlLayer extends Layer {
4554
this._renderRemoveCallback = scene.postRender.addEventListener(() => {
4655
let cp = this._viewer.camera.positionWC
4756
let cd = this._viewer.camera.direction
48-
const offset = this._viewer.getOffset()
57+
4958
this.eachOverlay((item) => {
5059
if (item && item.position) {
5160
let position = Transform.transformWGS84ToCartesian(item.position)
@@ -57,11 +66,6 @@ class HtmlLayer extends Layer {
5766
scene,
5867
position
5968
)
60-
61-
if (windowCoord) {
62-
windowCoord.x += offset.x
63-
windowCoord.y += offset.y
64-
}
6569
item._updateStyle(
6670
windowCoord,
6771
Cesium.Cartesian3.distance(position, cp),

src/modules/overlay/html/DivIcon.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class DivIcon extends Overlay {
2121
position: 'absolute',
2222
top: '0',
2323
left: '0',
24+
pointerEvents: 'auto',
2425
})
2526
this.content = content
2627
this._state = State.INITIALIZED

0 commit comments

Comments
 (0)